summaryrefslogtreecommitdiff
path: root/boost/align/aligned_allocator_adaptor.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/align/aligned_allocator_adaptor.hpp')
-rw-r--r--boost/align/aligned_allocator_adaptor.hpp47
1 files changed, 15 insertions, 32 deletions
diff --git a/boost/align/aligned_allocator_adaptor.hpp b/boost/align/aligned_allocator_adaptor.hpp
index 8905c215d3..c9fae1cf20 100644
--- a/boost/align/aligned_allocator_adaptor.hpp
+++ b/boost/align/aligned_allocator_adaptor.hpp
@@ -8,13 +8,13 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_HPP
-#include <boost/align/detail/addressof.hpp>
#include <boost/align/detail/is_alignment_constant.hpp>
#include <boost/align/detail/max_align.hpp>
#include <boost/align/detail/max_size.hpp>
#include <boost/align/align.hpp>
#include <boost/align/aligned_allocator_adaptor_forward.hpp>
#include <boost/align/alignment_of.hpp>
+#include <boost/core/pointer_traits.hpp>
#include <boost/static_assert.hpp>
#include <new>
@@ -32,39 +32,25 @@ namespace alignment {
template<class Allocator, std::size_t Alignment>
class aligned_allocator_adaptor
: public Allocator {
- BOOST_STATIC_ASSERT(detail::
- is_alignment_constant<Alignment>::value);
+ BOOST_STATIC_ASSERT(detail::is_alignment_constant<Alignment>::value);
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
typedef std::allocator_traits<Allocator> traits;
-
- typedef typename traits::
- template rebind_alloc<char> char_alloc;
-
- typedef typename traits::
- template rebind_traits<char> char_traits;
-
+ typedef typename traits::template rebind_alloc<char> char_alloc;
+ typedef typename traits::template rebind_traits<char> char_traits;
typedef typename char_traits::pointer char_ptr;
#else
- typedef typename Allocator::
- template rebind<char>::other char_alloc;
-
+ typedef typename Allocator::template rebind<char>::other char_alloc;
typedef typename char_alloc::pointer char_ptr;
#endif
public:
-#if !defined(BOOST_NO_CXX11_ALLOCATOR)
- typedef typename traits::value_type value_type;
- typedef typename traits::size_type size_type;
-#else
typedef typename Allocator::value_type value_type;
- typedef typename Allocator::size_type size_type;
-#endif
-
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef void* void_pointer;
typedef const void* const_void_pointer;
+ typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
private:
@@ -77,11 +63,11 @@ public:
template<class U>
struct rebind {
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
- typedef aligned_allocator_adaptor<typename traits::
- template rebind_alloc<U>, Alignment> other;
+ typedef aligned_allocator_adaptor<typename traits::template
+ rebind_alloc<U>, Alignment> other;
#else
- typedef aligned_allocator_adaptor<typename Allocator::
- template rebind<U>::other, Alignment> other;
+ typedef aligned_allocator_adaptor<typename Allocator::template
+ rebind<U>::other, Alignment> other;
#endif
};
@@ -120,10 +106,9 @@ public:
std::size_t n = s + min_align - 1;
char_alloc a(base());
char_ptr p = a.allocate(sizeof p + n);
- void* r = detail::addressof(*p) + sizeof p;
+ void* r = boost::pointer_traits<char_ptr>::to_address(p) + sizeof p;
(void)align(min_align, s, r, n);
- ::new(static_cast<void*>(static_cast<char_ptr*>(r)
- - 1)) char_ptr(p);
+ ::new(static_cast<void*>(static_cast<char_ptr*>(r) - 1)) char_ptr(p);
return static_cast<pointer>(r);
}
@@ -140,10 +125,9 @@ public:
#else
char_ptr p = a.allocate(sizeof p + n, h);
#endif
- void* r = detail::addressof(*p) + sizeof p;
+ void* r = boost::pointer_traits<char_ptr>::to_address(p) + sizeof p;
(void)align(min_align, s, r, n);
- ::new(static_cast<void*>(static_cast<char_ptr*>(r)
- - 1)) char_ptr(p);
+ ::new(static_cast<void*>(static_cast<char_ptr*>(r) - 1)) char_ptr(p);
return static_cast<pointer>(r);
}
@@ -152,8 +136,7 @@ public:
char_ptr r = *p;
p->~char_ptr();
char_alloc a(base());
- a.deallocate(r, sizeof r + size * sizeof(value_type) +
- min_align - 1);
+ a.deallocate(r, sizeof r + size * sizeof(value_type) + min_align - 1);
}
};