mirror of
https://github.com/boostorg/core.git
synced 2025-11-30 06:09:56 +01:00
Support C++03 implementations that require reference and const_pointer
This commit is contained in:
@@ -12,6 +12,12 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <new>
|
||||
#include <climits>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#define BOOST_CORE_NO_CXX11_ALLOCATOR
|
||||
#elif defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
|
||||
#define BOOST_CORE_NO_CXX11_ALLOCATOR
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
@@ -35,10 +41,28 @@ struct true_type {
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct add_reference {
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct add_reference<void> {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct add_reference<const void> {
|
||||
typedef const void type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct default_allocator {
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef typename add_reference<T>::type reference;
|
||||
typedef typename add_reference<const T>::type const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef true_type propagate_on_container_move_assignment;
|
||||
@@ -97,6 +121,18 @@ struct default_allocator {
|
||||
::operator delete(p, std::nothrow);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_CORE_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new(p) U(v);
|
||||
}
|
||||
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
p->~U();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
|
||||
Reference in New Issue
Block a user