diff options
| author | Stephen D. Huston <shuston@apache.org> | 2009-01-13 21:55:35 +0000 |
|---|---|---|
| committer | Stephen D. Huston <shuston@apache.org> | 2009-01-13 21:55:35 +0000 |
| commit | 4f97d4d7e1bd3fb047ba42bdfb001c2a9351f35a (patch) | |
| tree | 6f809a08dd0b0ea66f4219ac53cb2a69b6b699b4 /qpid/cpp/src | |
| parent | 7c68f45b197a7fc401f688bb29123548ac28b793 (diff) | |
| download | qpid-python-4f97d4d7e1bd3fb047ba42bdfb001c2a9351f35a.tar.gz | |
Revise allocator per patch in QPID-1458; Fixes QPID-1458
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@734251 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/InlineAllocator.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/InlineAllocator.h b/qpid/cpp/src/qpid/InlineAllocator.h index bf2f570599..152c02a299 100644 --- a/qpid/cpp/src/qpid/InlineAllocator.h +++ b/qpid/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*/ |
