summaryrefslogtreecommitdiff
path: root/boost/align/aligned_allocator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/align/aligned_allocator.hpp')
-rw-r--r--boost/align/aligned_allocator.hpp45
1 files changed, 20 insertions, 25 deletions
diff --git a/boost/align/aligned_allocator.hpp b/boost/align/aligned_allocator.hpp
index 9655e3dfb2..83af070c7a 100644
--- a/boost/align/aligned_allocator.hpp
+++ b/boost/align/aligned_allocator.hpp
@@ -9,16 +9,15 @@ http://boost.org/LICENSE_1_0.txt
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_HPP
-#include <boost/config.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/align/aligned_alloc.hpp>
-#include <boost/align/aligned_allocator_forward.hpp>
-#include <boost/align/alignment_of.hpp>
#include <boost/align/detail/addressof.hpp>
#include <boost/align/detail/is_alignment_constant.hpp>
#include <boost/align/detail/max_objects.hpp>
#include <boost/align/detail/max_size.hpp>
+#include <boost/align/aligned_alloc.hpp>
+#include <boost/align/aligned_allocator_forward.hpp>
+#include <boost/align/alignment_of.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/throw_exception.hpp>
#include <new>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@@ -72,15 +71,17 @@ public:
return detail::addressof(value);
}
- const_pointer address(const_reference value) const
- BOOST_NOEXCEPT {
+ const_pointer address(const_reference value) const BOOST_NOEXCEPT {
return detail::addressof(value);
}
pointer allocate(size_type size, const_void_pointer = 0) {
- void* p = aligned_alloc(min_align, sizeof(T) * size);
- if (size > 0 && !p) {
- ::boost::throw_exception(std::bad_alloc());
+ void* p = 0;
+ if (size > 0) {
+ p = aligned_alloc(min_align, sizeof(T) * size);
+ if (!p) {
+ ::boost::throw_exception(std::bad_alloc());
+ }
}
return static_cast<T*>(p);
}
@@ -97,28 +98,24 @@ public:
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class U, class... Args>
void construct(U* ptr, Args&&... args) {
- void* p = ptr;
- ::new(p) U(std::forward<Args>(args)...);
+ ::new(static_cast<void*>(ptr)) U(std::forward<Args>(args)...);
}
#else
template<class U, class V>
void construct(U* ptr, V&& value) {
- void* p = ptr;
- ::new(p) U(std::forward<V>(value));
+ ::new(static_cast<void*>(ptr)) U(std::forward<V>(value));
}
#endif
#else
template<class U, class V>
void construct(U* ptr, const V& value) {
- void* p = ptr;
- ::new(p) U(value);
+ ::new(static_cast<void*>(ptr)) U(value);
}
#endif
template<class U>
void construct(U* ptr) {
- void* p = ptr;
- ::new(p) U();
+ ::new(static_cast<void*>(ptr)) U();
}
template<class U>
@@ -145,17 +142,15 @@ public:
};
template<class T1, class T2, std::size_t Alignment>
-inline bool operator==(const aligned_allocator<T1,
- Alignment>&, const aligned_allocator<T2,
- Alignment>&) BOOST_NOEXCEPT
+inline bool operator==(const aligned_allocator<T1, Alignment>&,
+ const aligned_allocator<T2, Alignment>&) BOOST_NOEXCEPT
{
return true;
}
template<class T1, class T2, std::size_t Alignment>
-inline bool operator!=(const aligned_allocator<T1,
- Alignment>&, const aligned_allocator<T2,
- Alignment>&) BOOST_NOEXCEPT
+inline bool operator!=(const aligned_allocator<T1, Alignment>&,
+ const aligned_allocator<T2, Alignment>&) BOOST_NOEXCEPT
{
return false;
}