summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2009-01-13 21:55:35 +0000
committerStephen D. Huston <shuston@apache.org>2009-01-13 21:55:35 +0000
commit729e8dfff5d888d85c8d8c4201fa956378f4b917 (patch)
treeff586b6ad8a66e06337c5856de1acebe64c5e06b /cpp/src
parent766c218055567f4e387aab4678d8d1c840916465 (diff)
downloadqpid-python-729e8dfff5d888d85c8d8c4201fa956378f4b917.tar.gz
Revise allocator per patch in QPID-1458; Fixes QPID-1458
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@734251 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/InlineAllocator.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/cpp/src/qpid/InlineAllocator.h b/cpp/src/qpid/InlineAllocator.h
index bf2f570599..152c02a299 100644
--- a/cpp/src/qpid/InlineAllocator.h
+++ b/cpp/src/qpid/InlineAllocator.h
@@ -29,6 +29,10 @@
namespace qpid {
+template <typename RequestedType, typename InlineType, typename BaseAllocator, size_t Max>
+struct InlineRebind;
+
+
/**
* An allocator that has inline storage for up to Max objects
* of type BaseAllocator::value_type.
@@ -63,8 +67,7 @@ class InlineAllocator : public BaseAllocator {
template<typename T1>
struct rebind {
- typedef typename BaseAllocator::template rebind<T1>::other BaseOther;
- typedef InlineAllocator<BaseOther, Max> other;
+ typedef typename InlineRebind<T1, value_type, BaseAllocator, Max>::other other;
};
private:
@@ -79,6 +82,20 @@ class InlineAllocator : public BaseAllocator {
bool allocated;
};
+
+// Rebind: if RequestedType == InlineType, use the InlineAllocator,
+// otherwise, use the BaseAllocator without any inlining.
+
+template <typename RequestedType, typename InlineType, typename BaseAllocator, size_t Max>
+struct InlineRebind {
+ typedef typename BaseAllocator::template rebind<RequestedType>::other other;
+};
+
+template <typename T, typename BaseAllocator, size_t Max>
+struct InlineRebind<T, T, BaseAllocator, Max> {
+ typedef typename qpid::InlineAllocator<BaseAllocator, Max> other;
+};
+
} // namespace qpid
#endif /*!QPID_INLINEALLOCATOR_H*/