You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2008/06/06 00:06:02 UTC

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

Author: aconway
Date: Thu Jun  5 15:06:02 2008
New Revision: 663761

URL: http://svn.apache.org/viewvc?rev=663761&view=rev
Log:
Modified to work with boost-1.32

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

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h?rev=663761&r1=663760&r2=663761&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/InlineAllocator.h Thu Jun  5 15:06:02 2008
@@ -23,9 +23,9 @@
  */
 
 #include <memory>
-#include <boost/type_traits/aligned_storage.hpp>
-#include <boost/type_traits/alignment_of.hpp>
 #include <assert.h>
+#include <boost/type_traits/type_with_alignment.hpp>
+#include <boost/type_traits/alignment_of.hpp>
 
 namespace qpid {
 
@@ -46,14 +46,14 @@
     pointer allocate(size_type n) {
         if (n <= Max && !allocated) {
             allocated=true;
-            return reinterpret_cast<value_type*>(store.address());
+            return reinterpret_cast<value_type*>(address());
         }
         else 
             return BaseAllocator::allocate(n, 0);
     }
 
     void deallocate(pointer p, size_type n) {
-        if (p == store.address()) {
+        if (p == address()) {
             assert(allocated);
             allocated=false;
         }
@@ -68,10 +68,14 @@
     };
 
   private:
-    boost::aligned_storage<
-      sizeof(value_type)*Max,
-      boost::alignment_of<value_type>::value
-      > store;
+    // POD object with alignment and size to hold Max value_types.
+    static const size_t ALIGNMENT=boost::alignment_of<value_type>::value;
+    typedef typename boost::type_with_alignment<ALIGNMENT>::type Aligner;
+    union Store {
+      Aligner aligner_;
+      char sizer_[sizeof(value_type)*Max];
+    } store;
+    value_type* address() { return reinterpret_cast<value_type*>(&store); }
     bool allocated;
 };