You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by sh...@apache.org on 2009/01/13 22:55:36 UTC

svn commit: r734251 - /qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h

Author: shuston
Date: Tue Jan 13 13:55:35 2009
New Revision: 734251

URL: http://svn.apache.org/viewvc?rev=734251&view=rev
Log:
Revise allocator per patch in QPID-1458; Fixes QPID-1458

Modified:
    qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h

Modified: qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h?rev=734251&r1=734250&r2=734251&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h Tue Jan 13 13:55:35 2009
@@ -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 @@
 
     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 @@
     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*/