summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-06-05 22:06:02 +0000
committerAlan Conway <aconway@apache.org>2008-06-05 22:06:02 +0000
commit47ac86d631bac49199455337ec9529f3f54e47f3 (patch)
tree7cefddae5ee7267c53b260237c8b6b6a60a72184 /cpp/src
parent29df9f56808094b0009eb9d04c71d1d51f4e10a5 (diff)
downloadqpid-python-47ac86d631bac49199455337ec9529f3f54e47f3.tar.gz
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
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/InlineAllocator.h20
1 files changed, 12 insertions, 8 deletions
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 <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 @@ class InlineAllocator : public BaseAllocator {
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 @@ class InlineAllocator : public BaseAllocator {
};
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;
};