From 47ac86d631bac49199455337ec9529f3f54e47f3 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 5 Jun 2008 22:06:02 +0000 Subject: Modified to work with boost-1.32 git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@663761 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/InlineAllocator.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/InlineAllocator.h b/cpp/src/qpid/InlineAllocator.h index 80cf9d90a7..bf2f570599 100644 --- a/cpp/src/qpid/InlineAllocator.h +++ b/cpp/src/qpid/InlineAllocator.h @@ -23,9 +23,9 @@ */ #include -#include -#include #include +#include +#include namespace qpid { @@ -46,14 +46,14 @@ class InlineAllocator : public BaseAllocator { pointer allocate(size_type n) { if (n <= Max && !allocated) { allocated=true; - return reinterpret_cast(store.address()); + return reinterpret_cast(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 @@ class InlineAllocator : public BaseAllocator { }; private: - boost::aligned_storage< - sizeof(value_type)*Max, - boost::alignment_of::value - > store; + // POD object with alignment and size to hold Max value_types. + static const size_t ALIGNMENT=boost::alignment_of::value; + typedef typename boost::type_with_alignment::type Aligner; + union Store { + Aligner aligner_; + char sizer_[sizeof(value_type)*Max]; + } store; + value_type* address() { return reinterpret_cast(&store); } bool allocated; }; -- cgit v1.2.1