mirror of
https://github.com/boostorg/core.git
synced 2025-05-10 07:13:54 +00:00
Revise allocator_access implementation
This commit is contained in:
parent
65901249d5
commit
376aa7aa31
@ -21,9 +21,8 @@ templates to simplify allocator use. It provides the same functionality as the
|
|||||||
C++ standard library `std::allocator_traits` but with individual templates for
|
C++ standard library `std::allocator_traits` but with individual templates for
|
||||||
each allocator feature.
|
each allocator feature.
|
||||||
|
|
||||||
This implementation supports C++03 and above. These facilities also simplify
|
These facilities also simplify existing libraries by avoiding having to check
|
||||||
existing libraries by avoiding having to check for `BOOST_NO_CXX11_ALLOCATOR`
|
for `BOOST_NO_CXX11_ALLOCATOR` and conditionally use `std::allocator_traits`.
|
||||||
and conditionally use `std::allocator_traits`.
|
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);
|
|||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n,
|
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n,
|
||||||
allocator_const_void_pointer_t<A> hint);
|
allocator_const_void_pointer_t<A> h);
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
void allocator_deallocate(A& a, allocator_pointer_t<A> p,
|
void allocator_deallocate(A& a, allocator_pointer_t<A> p,
|
||||||
|
@ -8,40 +8,53 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#ifndef BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
#ifndef BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
||||||
#define BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
#define BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
#include <boost/core/pointer_traits.hpp>
|
#include <boost/core/pointer_traits.hpp>
|
||||||
|
#if !defined(BOOST_MSVC)
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#if defined(BOOST_DINKUMWARE_STDLIB)
|
#else
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#endif
|
#endif
|
||||||
#include <new>
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#endif
|
#endif
|
||||||
|
#include <new>
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) || \
|
namespace boost {
|
||||||
defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
namespace detail {
|
||||||
#define BOOST_CORE_ALLOCATOR_DETECTION
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
struct alloc_false {
|
||||||
|
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
template<class>
|
||||||
|
struct alloc_void {
|
||||||
|
typedef void type;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
} /* detail */
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
struct allocator_value_type {
|
struct allocator_value_type {
|
||||||
typedef typename A::value_type type;
|
typedef typename A::value_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
template<class>
|
struct allocator_pointer {
|
||||||
struct alloc_void {
|
typedef typename A::pointer type;
|
||||||
typedef void type;
|
|
||||||
};
|
};
|
||||||
|
#elif defined(BOOST_MSVC)
|
||||||
} /* detail */
|
template<class A>
|
||||||
|
struct allocator_pointer {
|
||||||
|
typedef typename std::allocator_traits<A>::pointer type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_pointer {
|
struct allocator_pointer {
|
||||||
typedef typename A::value_type* type;
|
typedef typename A::value_type* type;
|
||||||
@ -52,7 +65,19 @@ struct allocator_pointer<A,
|
|||||||
typename detail::alloc_void<typename A::pointer>::type> {
|
typename detail::alloc_void<typename A::pointer>::type> {
|
||||||
typedef typename A::pointer type;
|
typedef typename A::pointer type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
struct allocator_const_pointer {
|
||||||
|
typedef typename A::const_pointer type;
|
||||||
|
};
|
||||||
|
#elif defined(BOOST_MSVC)
|
||||||
|
template<class A>
|
||||||
|
struct allocator_const_pointer {
|
||||||
|
typedef typename std::allocator_traits<A>::const_pointer type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_const_pointer {
|
struct allocator_const_pointer {
|
||||||
typedef typename pointer_traits<typename
|
typedef typename pointer_traits<typename
|
||||||
@ -65,7 +90,14 @@ struct allocator_const_pointer<A,
|
|||||||
typename detail::alloc_void<typename A::const_pointer>::type> {
|
typename detail::alloc_void<typename A::const_pointer>::type> {
|
||||||
typedef typename A::const_pointer type;
|
typedef typename A::const_pointer type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
struct allocator_void_pointer {
|
||||||
|
typedef typename A::template rebind<void>::other::pointer type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_void_pointer {
|
struct allocator_void_pointer {
|
||||||
typedef typename pointer_traits<typename
|
typedef typename pointer_traits<typename
|
||||||
@ -78,7 +110,14 @@ struct allocator_void_pointer<A,
|
|||||||
typename detail::alloc_void<typename A::void_pointer>::type> {
|
typename detail::alloc_void<typename A::void_pointer>::type> {
|
||||||
typedef typename A::void_pointer type;
|
typedef typename A::void_pointer type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
struct allocator_const_void_pointer {
|
||||||
|
typedef typename A::template rebind<void>::other::const_pointer type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_const_void_pointer {
|
struct allocator_const_void_pointer {
|
||||||
typedef typename pointer_traits<typename
|
typedef typename pointer_traits<typename
|
||||||
@ -91,7 +130,14 @@ struct allocator_const_void_pointer<A,
|
|||||||
typename detail::alloc_void<typename A::const_void_pointer>::type> {
|
typename detail::alloc_void<typename A::const_void_pointer>::type> {
|
||||||
typedef typename A::const_void_pointer type;
|
typedef typename A::const_void_pointer type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
struct allocator_difference_type {
|
||||||
|
typedef typename A::difference_type type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_difference_type {
|
struct allocator_difference_type {
|
||||||
typedef typename pointer_traits<typename
|
typedef typename pointer_traits<typename
|
||||||
@ -103,8 +149,14 @@ struct allocator_difference_type<A,
|
|||||||
typename detail::alloc_void<typename A::difference_type>::type> {
|
typename detail::alloc_void<typename A::difference_type>::type> {
|
||||||
typedef typename A::difference_type type;
|
typedef typename A::difference_type type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
struct allocator_size_type {
|
||||||
|
typedef typename A::size_type type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_size_type {
|
struct allocator_size_type {
|
||||||
typedef typename std::make_unsigned<typename
|
typedef typename std::make_unsigned<typename
|
||||||
@ -116,28 +168,17 @@ struct allocator_size_type<A,
|
|||||||
typename detail::alloc_void<typename A::size_type>::type> {
|
typename detail::alloc_void<typename A::size_type>::type> {
|
||||||
typedef typename A::size_type type;
|
typedef typename A::size_type type;
|
||||||
};
|
};
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
template<class A>
|
template<class A>
|
||||||
struct allocator_size_type {
|
struct allocator_propagate_on_container_copy_assignment {
|
||||||
typedef typename A::size_type type;
|
typedef detail::alloc_false type;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
|
||||||
typedef std::false_type alloc_false_type;
|
|
||||||
#else
|
#else
|
||||||
struct alloc_false_type {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
|
||||||
|
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_propagate_on_container_copy_assignment {
|
struct allocator_propagate_on_container_copy_assignment {
|
||||||
typedef detail::alloc_false_type type;
|
typedef std::false_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
@ -146,10 +187,17 @@ struct allocator_propagate_on_container_copy_assignment<A,
|
|||||||
A::propagate_on_container_copy_assignment>::type> {
|
A::propagate_on_container_copy_assignment>::type> {
|
||||||
typedef typename A::propagate_on_container_copy_assignment type;
|
typedef typename A::propagate_on_container_copy_assignment type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
struct allocator_propagate_on_container_move_assignment {
|
||||||
|
typedef detail::alloc_false type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_propagate_on_container_move_assignment {
|
struct allocator_propagate_on_container_move_assignment {
|
||||||
typedef detail::alloc_false_type type;
|
typedef std::false_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
@ -158,10 +206,17 @@ struct allocator_propagate_on_container_move_assignment<A,
|
|||||||
A::propagate_on_container_move_assignment>::type> {
|
A::propagate_on_container_move_assignment>::type> {
|
||||||
typedef typename A::propagate_on_container_move_assignment type;
|
typedef typename A::propagate_on_container_move_assignment type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
struct allocator_propagate_on_container_swap {
|
||||||
|
typedef detail::alloc_false type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_propagate_on_container_swap {
|
struct allocator_propagate_on_container_swap {
|
||||||
typedef detail::alloc_false_type type;
|
typedef std::false_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
@ -170,52 +225,46 @@ struct allocator_propagate_on_container_swap<A,
|
|||||||
A::propagate_on_container_swap>::type> {
|
A::propagate_on_container_swap>::type> {
|
||||||
typedef typename A::propagate_on_container_swap type;
|
typedef typename A::propagate_on_container_swap type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
template<class A, class = void>
|
template<class A>
|
||||||
struct allocator_is_always_equal {
|
struct allocator_is_always_equal {
|
||||||
typedef typename std::is_empty<A>::type type;
|
typedef detail::alloc_false type;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
template<class A, class = void>
|
template<class A, class = void>
|
||||||
struct allocator_is_always_equal {
|
struct allocator_is_always_equal {
|
||||||
typedef typename detail::alloc_false_type type;
|
typedef typename std::is_empty<A>::type type;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
struct allocator_is_always_equal<A,
|
struct allocator_is_always_equal<A,
|
||||||
typename detail::alloc_void<typename A::is_always_equal>::type> {
|
typename detail::alloc_void<typename A::is_always_equal>::type> {
|
||||||
typedef typename A::is_always_equal type;
|
typedef typename A::is_always_equal type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A, class T>
|
||||||
|
struct allocator_rebind {
|
||||||
|
typedef typename A::template rebind<T>::other type;
|
||||||
|
};
|
||||||
|
#elif defined(BOOST_MSVC)
|
||||||
|
template<class A, class T>
|
||||||
|
struct allocator_rebind {
|
||||||
|
typedef typename std::allocator_traits<A>::template rebind_alloc<T> type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class, class>
|
template<class, class>
|
||||||
struct alloc_to { };
|
struct alloc_to { };
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
|
||||||
template<template<class, class...> class A, class T, class U, class... V>
|
template<template<class, class...> class A, class T, class U, class... V>
|
||||||
struct alloc_to<A<U, V...>, T> {
|
struct alloc_to<A<U, V...>, T> {
|
||||||
typedef A<T, V...> type;
|
typedef A<T, V...> type;
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
template<template<class> class A, class T, class U>
|
|
||||||
struct alloc_to<A<U>, T> {
|
|
||||||
typedef A<T> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<template<class, class> class A, class T, class U1, class U2>
|
|
||||||
struct alloc_to<A<U1, U2>, T> {
|
|
||||||
typedef A<T, U2> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<template<class, class, class> class A, class T, class U1, class U2,
|
|
||||||
class U3>
|
|
||||||
struct alloc_to<A<U1, U2, U3>, T> {
|
|
||||||
typedef A<T, U2, U3> type;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
} /* detail */
|
||||||
|
|
||||||
@ -229,6 +278,7 @@ struct allocator_rebind<A, T,
|
|||||||
typename detail::alloc_void<typename A::template rebind<T>::other>::type> {
|
typename detail::alloc_void<typename A::template rebind<T>::other>::type> {
|
||||||
typedef typename A::template rebind<T>::other type;
|
typedef typename A::template rebind<T>::other type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
inline typename allocator_pointer<A>::type
|
inline typename allocator_pointer<A>::type
|
||||||
@ -237,98 +287,6 @@ allocator_allocate(A& a, typename allocator_size_type<A>::type n)
|
|||||||
return a.allocate(n);
|
return a.allocate(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template<bool, class = void>
|
|
||||||
struct alloc_if { };
|
|
||||||
|
|
||||||
template<class R>
|
|
||||||
struct alloc_if<true, R> {
|
|
||||||
typedef R type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class>
|
|
||||||
struct alloc_enable {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(BOOST_DINKUMWARE_STDLIB)
|
|
||||||
template<class T>
|
|
||||||
struct alloc_enable<std::allocator<T> > {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
|
||||||
template<class T>
|
|
||||||
T alloc_declval() BOOST_NOEXCEPT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
|
||||||
template<class>
|
|
||||||
struct alloc_yes {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct alloc_no {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class, class, class, class = void>
|
|
||||||
struct alloc_has_allocate {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
|
|
||||||
template<class A, class N, class H>
|
|
||||||
struct alloc_has_allocate<A, N, H,
|
|
||||||
decltype(alloc_declval<A&>().allocate(alloc_declval<N>(),
|
|
||||||
alloc_declval<H>()), void())> {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
|
||||||
};
|
|
||||||
#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
|
||||||
template<class A, class N, class H>
|
|
||||||
struct alloc_has_allocate<A, N, H, void> {
|
|
||||||
private:
|
|
||||||
template<class U>
|
|
||||||
static auto call(int, U& a) ->
|
|
||||||
alloc_yes<decltype(a.allocate(alloc_declval<N>(),
|
|
||||||
alloc_declval<H>()))>;
|
|
||||||
|
|
||||||
template<class U>
|
|
||||||
static alloc_no call(long, U&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = decltype(call(0,
|
|
||||||
alloc_declval<A&>()))::value;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
|
||||||
|
|
||||||
template<class A>
|
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
|
||||||
detail::alloc_has_allocate<A, typename allocator_size_type<A>::type,
|
|
||||||
typename allocator_const_void_pointer<A>::type>::value,
|
|
||||||
typename allocator_pointer<A>::type>::type
|
|
||||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
|
||||||
typename allocator_const_void_pointer<A>::type h)
|
|
||||||
{
|
|
||||||
return a.allocate(n, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A>
|
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
|
||||||
!detail::alloc_has_allocate<A, typename allocator_size_type<A>::type,
|
|
||||||
typename allocator_const_void_pointer<A>::type>::value,
|
|
||||||
typename allocator_pointer<A>::type>::type
|
|
||||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
|
||||||
typename allocator_const_void_pointer<A>::type)
|
|
||||||
{
|
|
||||||
return a.allocate(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
inline void
|
inline void
|
||||||
allocator_deallocate(A& a, typename allocator_pointer<A>::type p,
|
allocator_deallocate(A& a, typename allocator_pointer<A>::type p,
|
||||||
@ -337,191 +295,158 @@ allocator_deallocate(A& a, typename allocator_pointer<A>::type p,
|
|||||||
a.deallocate(p, n);
|
a.deallocate(p, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
template<class, class, class = void>
|
inline typename allocator_pointer<A>::type
|
||||||
struct alloc_has_construct {
|
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
typename allocator_const_void_pointer<A>::type h)
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
|
|
||||||
template<class A, class T>
|
|
||||||
struct alloc_has_construct<A, T,
|
|
||||||
decltype(alloc_declval<A&>().construct(alloc_declval<T*>()), void())> {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
|
||||||
};
|
|
||||||
#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
|
||||||
template<class A, class T>
|
|
||||||
struct alloc_has_construct<A, T, void> {
|
|
||||||
private:
|
|
||||||
template<class U>
|
|
||||||
static auto call(int, U& a) ->
|
|
||||||
alloc_yes<decltype(a.construct(alloc_declval<T*>()))>;
|
|
||||||
|
|
||||||
template<class U>
|
|
||||||
static alloc_no call(long, U&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = decltype(call(0,
|
|
||||||
alloc_declval<A&>()))::value;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
|
||||||
|
|
||||||
template<class A, class T>
|
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
|
||||||
detail::alloc_has_construct<A, T>::value>::type
|
|
||||||
allocator_construct(A& a, T* p)
|
|
||||||
{
|
{
|
||||||
a.construct(p);
|
return a.allocate(n, h);
|
||||||
}
|
}
|
||||||
|
#elif defined(BOOST_MSVC)
|
||||||
template<class A, class T>
|
template<class A>
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
inline typename allocator_pointer<A>::type
|
||||||
!detail::alloc_has_construct<A, T>::value>::type
|
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||||
allocator_construct(A&, T* p)
|
typename allocator_const_void_pointer<A>::type h)
|
||||||
{
|
{
|
||||||
::new((void*)p) T();
|
return std::allocator_traits<A>::allocate(a, n, h);
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
|
||||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template<class, class, class, class...>
|
|
||||||
struct alloc_has_construct_args {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
|
|
||||||
template<class A, class T, class... Args>
|
|
||||||
struct alloc_has_construct_args<decltype(alloc_declval<A
|
|
||||||
&>().construct(alloc_declval<T*>(), alloc_declval<Args&&>()...), void()),
|
|
||||||
A, T, Args...> {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
|
||||||
};
|
|
||||||
#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
|
||||||
template<class A, class T, class... Args>
|
|
||||||
struct alloc_has_construct_args<void, A, T, Args...> {
|
|
||||||
private:
|
|
||||||
template<class U>
|
|
||||||
static auto call(int, U& a) ->
|
|
||||||
alloc_yes<decltype(a.construct(alloc_declval<T*>(),
|
|
||||||
alloc_declval<Args&&>()...))>;
|
|
||||||
|
|
||||||
template<class U>
|
|
||||||
static alloc_no call(long, U&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = decltype(call(0,
|
|
||||||
alloc_declval<A&>()))::value;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
|
||||||
|
|
||||||
template<class A, class T, class V, class... Args>
|
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
|
||||||
detail::alloc_has_construct_args<void, A, T, V, Args...>::value>::type
|
|
||||||
allocator_construct(A& a, T* p, V&& v, Args&&... args)
|
|
||||||
{
|
|
||||||
a.construct(p, std::forward<V>(v), std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A, class T, class V, class... Args>
|
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
|
||||||
!detail::alloc_has_construct_args<void, A, T, V, Args...>::value>::type
|
|
||||||
allocator_construct(A&, T* p, V&& v, Args&&... args)
|
|
||||||
{
|
|
||||||
::new((void*)p) T(std::forward<V>(v), std::forward<Args>(args)...);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class, class, class, class = void>
|
template<class, class, class, class = void>
|
||||||
struct alloc_has_construct_arg {
|
struct alloc_has_allocate {
|
||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
|
template<class A, class N, class H>
|
||||||
template<class A, class T, class V>
|
struct alloc_has_allocate<A, N, H,
|
||||||
struct alloc_has_construct_arg<A, T, V,
|
typename alloc_void<decltype(std::declval<A&>().allocate(std::declval<N>(),
|
||||||
decltype(alloc_declval<A&>().construct(alloc_declval<T*>(),
|
std::declval<H>()))>::type> {
|
||||||
alloc_declval<V>()), void())> {
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||||
};
|
};
|
||||||
#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
|
||||||
template<class A, class T, class V>
|
|
||||||
struct alloc_has_construct_arg<A, T, V, void> {
|
|
||||||
private:
|
|
||||||
template<class U>
|
|
||||||
static auto call(int, U& a) ->
|
|
||||||
alloc_yes<decltype(a.construct(alloc_declval<T*>(),
|
|
||||||
alloc_declval<V>()))>;
|
|
||||||
|
|
||||||
template<class U>
|
|
||||||
static alloc_no call(long, U&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = decltype(call(0,
|
|
||||||
alloc_declval<A&>()))::value;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
} /* detail */
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
template<class A>
|
||||||
template<class A, class T, class V>
|
inline typename std::enable_if<detail::alloc_has_allocate<A,
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
typename allocator_size_type<A>::type,
|
||||||
detail::alloc_has_construct_arg<A, T, V&&>::value>::type
|
typename allocator_const_void_pointer<A>::type>::value,
|
||||||
allocator_construct(A& a, T* p, V&& v)
|
typename allocator_pointer<A>::type>::type
|
||||||
|
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||||
|
typename allocator_const_void_pointer<A>::type h)
|
||||||
{
|
{
|
||||||
a.construct(p, std::forward<V>(v));
|
return a.allocate(n, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class A>
|
||||||
|
inline typename std::enable_if<!detail::alloc_has_allocate<A,
|
||||||
|
typename allocator_size_type<A>::type,
|
||||||
|
typename allocator_const_void_pointer<A>::type>::value,
|
||||||
|
typename allocator_pointer<A>::type>::type
|
||||||
|
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||||
|
typename allocator_const_void_pointer<A>::type)
|
||||||
|
{
|
||||||
|
return a.allocate(n);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A, class T>
|
||||||
|
inline void
|
||||||
|
allocator_construct(A&, T* p)
|
||||||
|
{
|
||||||
|
::new((void*)p) T();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
template<class A, class T, class V, class... Args>
|
||||||
|
inline void
|
||||||
|
allocator_construct(A&, T* p, V&& v, Args&&... args)
|
||||||
|
{
|
||||||
|
::new((void*)p) T(std::forward<V>(v), std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
#else
|
||||||
template<class A, class T, class V>
|
template<class A, class T, class V>
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
inline void
|
||||||
!detail::alloc_has_construct_arg<A, T, V&&>::value>::type
|
|
||||||
allocator_construct(A&, T* p, V&& v)
|
allocator_construct(A&, T* p, V&& v)
|
||||||
{
|
{
|
||||||
::new((void*)p) T(std::forward<V>(v));
|
::new((void*)p) T(std::forward<V>(v));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
template<class A, class T, class V>
|
template<class A, class T, class V>
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
inline void
|
||||||
detail::alloc_has_construct_arg<A, T, const V&>::value>::type
|
|
||||||
allocator_construct(A& a, T* p, const V& v)
|
|
||||||
{
|
|
||||||
a.construct(p, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A, class T, class V>
|
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
|
||||||
!detail::alloc_has_construct_arg<A, T, const V&>::value>::type
|
|
||||||
allocator_construct(A&, T* p, const V& v)
|
allocator_construct(A&, T* p, const V& v)
|
||||||
{
|
{
|
||||||
::new((void*)p) T(v);
|
::new((void*)p) T(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class A, class T, class V>
|
template<class A, class T, class V>
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
inline void
|
||||||
detail::alloc_has_construct_arg<A, T, V&>::value>::type
|
|
||||||
allocator_construct(A& a, T* p, V& v)
|
|
||||||
{
|
|
||||||
a.construct(p, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A, class T, class V>
|
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
|
||||||
!detail::alloc_has_construct_arg<A, T, V&>::value>::type
|
|
||||||
allocator_construct(A&, T* p, V& v)
|
allocator_construct(A&, T* p, V& v)
|
||||||
{
|
{
|
||||||
::new((void*)p) T(v);
|
::new((void*)p) T(v);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(BOOST_MSVC)
|
||||||
|
template<class A, class T, class... Args>
|
||||||
|
inline void
|
||||||
|
allocator_construct(A& a, T* p, Args&&... args)
|
||||||
|
{
|
||||||
|
std::allocator_traits<A>::construct(a, p, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<class, class, class, class...>
|
||||||
|
struct alloc_has_construct {
|
||||||
|
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class A, class T, class... Args>
|
||||||
|
struct alloc_has_construct<typename alloc_void<decltype(std::declval<A
|
||||||
|
&>().construct(std::declval<T*>(), std::declval<Args&&>()...))>::type,
|
||||||
|
A, T, Args...> {
|
||||||
|
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* detail */
|
||||||
|
|
||||||
|
template<class A, class T, class... Args>
|
||||||
|
inline typename std::enable_if<detail::alloc_has_construct<void, A, T,
|
||||||
|
Args...>::value>::type
|
||||||
|
allocator_construct(A& a, T* p, Args&&... args)
|
||||||
|
{
|
||||||
|
a.construct(p, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class A, class T, class... Args>
|
||||||
|
inline typename std::enable_if<!detail::alloc_has_construct<void, A, T,
|
||||||
|
Args...>::value>::type
|
||||||
|
allocator_construct(A&, T* p, Args&&... args)
|
||||||
|
{
|
||||||
|
::new((void*)p) T(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A, class T>
|
||||||
|
inline void
|
||||||
|
allocator_destroy(A&, T* p)
|
||||||
|
{
|
||||||
|
p->~T();
|
||||||
|
(void)p;
|
||||||
|
}
|
||||||
|
#elif defined(BOOST_MSVC)
|
||||||
|
template<class A, class T>
|
||||||
|
inline void
|
||||||
|
allocator_destroy(A& a, T* p)
|
||||||
|
{
|
||||||
|
std::allocator_traits<A>::destroy(a, p);
|
||||||
|
}
|
||||||
|
#else
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class, class, class = void>
|
template<class, class, class = void>
|
||||||
@ -529,48 +454,46 @@ struct alloc_has_destroy {
|
|||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
|
|
||||||
template<class A, class T>
|
template<class A, class T>
|
||||||
struct alloc_has_destroy<A, T,
|
struct alloc_has_destroy<A, T,
|
||||||
decltype(alloc_declval<A&>().destroy(alloc_declval<T*>()), void())> {
|
typename alloc_void<decltype(std::declval<A
|
||||||
|
&>().destroy(std::declval<T*>()))>::type> {
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||||
};
|
};
|
||||||
#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
|
||||||
template<class A, class T>
|
|
||||||
struct alloc_has_destroy<A, T, void> {
|
|
||||||
private:
|
|
||||||
template<class U>
|
|
||||||
static auto call(int, U& a) ->
|
|
||||||
alloc_yes<decltype(a.destroy(alloc_declval<T*>()))>;
|
|
||||||
|
|
||||||
template<class U>
|
|
||||||
static alloc_no call(long, U&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = decltype(call(0,
|
|
||||||
alloc_declval<A&>()))::value;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
} /* detail */
|
||||||
|
|
||||||
template<class A, class T>
|
template<class A, class T>
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
inline typename std::enable_if<detail::alloc_has_destroy<A, T>::value>::type
|
||||||
detail::alloc_has_destroy<A, T>::value>::type
|
|
||||||
allocator_destroy(A& a, T* p)
|
allocator_destroy(A& a, T* p)
|
||||||
{
|
{
|
||||||
a.destroy(p);
|
a.destroy(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class A, class T>
|
template<class A, class T>
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
inline typename std::enable_if<!detail::alloc_has_destroy<A, T>::value>::type
|
||||||
!detail::alloc_has_destroy<A, T>::value>::type
|
|
||||||
allocator_destroy(A&, T* p)
|
allocator_destroy(A&, T* p)
|
||||||
{
|
{
|
||||||
p->~T();
|
p->~T();
|
||||||
(void)p;
|
(void)p;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
inline typename allocator_size_type<A>::type
|
||||||
|
allocator_max_size(const A& a)
|
||||||
|
{
|
||||||
|
return a.max_size();
|
||||||
|
}
|
||||||
|
#elif defined(BOOST_MSVC)
|
||||||
|
template<class A>
|
||||||
|
inline typename allocator_size_type<A>::type
|
||||||
|
allocator_max_size(const A& a)
|
||||||
|
{
|
||||||
|
return std::allocator_traits<A>::max_size(a);
|
||||||
|
}
|
||||||
|
#else
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class, class = void>
|
template<class, class = void>
|
||||||
@ -578,33 +501,17 @@ struct alloc_has_max_size {
|
|||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
|
|
||||||
template<class A>
|
template<class A>
|
||||||
struct alloc_has_max_size<A,
|
struct alloc_has_max_size<A,
|
||||||
decltype(alloc_declval<const A&>().max_size(), void())> {
|
typename alloc_void<decltype(std::declval<const
|
||||||
|
A&>().max_size())>::type> {
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||||
};
|
};
|
||||||
#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
|
||||||
template<class A>
|
|
||||||
struct alloc_has_max_size<A, void> {
|
|
||||||
private:
|
|
||||||
template<class U>
|
|
||||||
static auto call(int, const U& a) -> alloc_yes<decltype(a.max_size())>;
|
|
||||||
|
|
||||||
template<class U>
|
|
||||||
static alloc_no call(long, const U&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = decltype(call(0,
|
|
||||||
alloc_declval<const A&>()))::value;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
} /* detail */
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
inline typename std::enable_if<detail::alloc_has_max_size<A>::value,
|
||||||
detail::alloc_has_max_size<A>::value,
|
|
||||||
typename allocator_size_type<A>::type>::type
|
typename allocator_size_type<A>::type>::type
|
||||||
allocator_max_size(const A& a)
|
allocator_max_size(const A& a)
|
||||||
{
|
{
|
||||||
@ -612,15 +519,30 @@ allocator_max_size(const A& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
inline typename std::enable_if<!detail::alloc_has_max_size<A>::value,
|
||||||
!detail::alloc_has_max_size<A>::value,
|
|
||||||
typename allocator_size_type<A>::type>::type
|
typename allocator_size_type<A>::type>::type
|
||||||
allocator_max_size(const A&)
|
allocator_max_size(const A&)
|
||||||
{
|
{
|
||||||
return (std::numeric_limits<typename
|
return (std::numeric_limits<typename
|
||||||
allocator_size_type<A>::type>::max)() / sizeof(typename A::value_type);
|
allocator_size_type<A>::type>::max)() / sizeof(typename A::value_type);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class A>
|
||||||
|
inline A
|
||||||
|
allocator_select_on_container_copy_construction(const A& a)
|
||||||
|
{
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
#elif defined(BOOST_MSVC)
|
||||||
|
template<class A>
|
||||||
|
inline A
|
||||||
|
allocator_select_on_container_copy_construction(const A& a)
|
||||||
|
{
|
||||||
|
return std::allocator_traits<A>::select_on_container_copy_construction(a);
|
||||||
|
}
|
||||||
|
#else
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class, class = void>
|
template<class, class = void>
|
||||||
@ -628,47 +550,29 @@ struct alloc_has_soccc {
|
|||||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)
|
|
||||||
template<class A>
|
template<class A>
|
||||||
struct alloc_has_soccc<A,
|
struct alloc_has_soccc<A,
|
||||||
decltype(alloc_declval<const A&>().select_on_container_copy_construction(),
|
typename alloc_void<decltype(std::declval<const
|
||||||
void())> {
|
A&>().select_on_container_copy_construction())>::type> {
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||||
};
|
};
|
||||||
#elif defined(BOOST_MSVC) && BOOST_MSVC == 1800
|
|
||||||
template<class A>
|
|
||||||
struct alloc_has_soccc<A, void> {
|
|
||||||
private:
|
|
||||||
template<class U>
|
|
||||||
static auto call(int, const U& a) ->
|
|
||||||
alloc_yes<decltype(a.select_on_container_copy_construction())>;
|
|
||||||
|
|
||||||
template<class U>
|
|
||||||
static alloc_no call(long, const U&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTEXPR bool value = decltype(call(0,
|
|
||||||
alloc_declval<const A&>()))::value;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* detail */
|
} /* detail */
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
inline typename detail::alloc_if<detail::alloc_enable<A>::value &&
|
inline typename std::enable_if<detail::alloc_has_soccc<A>::value, A>::type
|
||||||
detail::alloc_has_soccc<A>::value, A>::type
|
|
||||||
allocator_select_on_container_copy_construction(const A& a)
|
allocator_select_on_container_copy_construction(const A& a)
|
||||||
{
|
{
|
||||||
return a.select_on_container_copy_construction();
|
return a.select_on_container_copy_construction();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
inline typename detail::alloc_if<!detail::alloc_enable<A>::value ||
|
inline typename std::enable_if<!detail::alloc_has_soccc<A>::value, A>::type
|
||||||
!detail::alloc_has_soccc<A>::value, A>::type
|
|
||||||
allocator_select_on_container_copy_construction(const A& a)
|
allocator_select_on_container_copy_construction(const A& a)
|
||||||
{
|
{
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||||
template<class A>
|
template<class A>
|
||||||
|
@ -6,7 +6,7 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
(http://www.boost.org/LICENSE_1_0.txt)
|
(http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
#include <boost/core/alloc_construct.hpp>
|
#include <boost/core/alloc_construct.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
@ -8,53 +8,51 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
typedef int* pointer;
|
typedef T value_type;
|
||||||
typedef int size_type;
|
typedef std::size_t size_type;
|
||||||
|
typedef T* pointer;
|
||||||
|
typedef const T* const_pointer;
|
||||||
|
template<class U>
|
||||||
|
struct rebind {
|
||||||
|
typedef A1<U> other;
|
||||||
|
};
|
||||||
A1()
|
A1()
|
||||||
: value() { }
|
: value() { }
|
||||||
|
T* allocate(std::size_t n, const void*) {
|
||||||
pointer allocate(size_type n) {
|
|
||||||
value = n;
|
value = n;
|
||||||
return &value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
std::size_t value;
|
||||||
size_type value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
typedef int* pointer;
|
typedef T value_type;
|
||||||
typedef int size_type;
|
|
||||||
|
|
||||||
A2()
|
A2()
|
||||||
: value() { }
|
: value() { }
|
||||||
|
T* allocate(std::size_t n) {
|
||||||
pointer allocate(size_type n) {
|
|
||||||
value = n;
|
value = n;
|
||||||
return &value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
std::size_t value;
|
||||||
pointer allocate(size_type n, const void*) {
|
|
||||||
value = n + 1;
|
|
||||||
return &value;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_type value;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
A1 a;
|
A1<int> a;
|
||||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 1, 0), 1);
|
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
|
||||||
|
BOOST_TEST_EQ(a.value, 5);
|
||||||
}
|
}
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
{
|
{
|
||||||
A2 a;
|
A2<int> a;
|
||||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 1, 0), 2);
|
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
|
||||||
|
BOOST_TEST_EQ(a.value, 5);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
|
@ -8,24 +8,24 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A {
|
struct A {
|
||||||
typedef int* pointer;
|
typedef T value_type;
|
||||||
typedef int size_type;
|
typedef T* pointer;
|
||||||
|
typedef std::size_t size_type;
|
||||||
A()
|
A()
|
||||||
: value() { }
|
: value() { }
|
||||||
|
T* allocate(std::size_t n) {
|
||||||
pointer allocate(size_type n) {
|
|
||||||
value = n;
|
value = n;
|
||||||
return &value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
std::size_t value;
|
||||||
size_type value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
A a;
|
A<int> a;
|
||||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 5), 5);
|
BOOST_TEST_NOT(boost::allocator_allocate(a, 5));
|
||||||
|
BOOST_TEST_EQ(a.value, 5);
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,22 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
typedef char value_type;
|
typedef T value_type;
|
||||||
typedef int* pointer;
|
typedef int* const_pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
typedef char value_type;
|
typedef T value_type;
|
||||||
typedef int* pointer;
|
|
||||||
typedef const bool* const_pointer;
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const char*,
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||||
boost::allocator_const_pointer<A1>::type>));
|
boost::allocator_const_pointer<A1<char> >::type>));
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const bool*,
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
boost::allocator_const_pointer<A2>::type>));
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||||
|
boost::allocator_const_pointer<A2<int> >::type>));
|
||||||
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,31 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
typedef int* pointer;
|
typedef T value_type;
|
||||||
|
typedef int* const_pointer;
|
||||||
|
typedef int* const_void_pointer;
|
||||||
|
template<class U>
|
||||||
|
struct rebind {
|
||||||
|
typedef A1<U> other;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
typedef int* pointer;
|
typedef T value_type;
|
||||||
typedef const bool* const_void_pointer;
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||||
|
boost::allocator_const_void_pointer<A1<char> >::type>));
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
|
||||||
boost::allocator_const_void_pointer<A1>::type>));
|
boost::allocator_const_void_pointer<A2<int> >::type>));
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const bool*,
|
#endif
|
||||||
boost::allocator_const_void_pointer<A2>::type>));
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -6,43 +6,40 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
(http://www.boost.org/LICENSE_1_0.txt)
|
(http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
#include <boost/core/default_allocator.hpp>
|
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
struct S {
|
template<class T>
|
||||||
S(int v)
|
struct A1 {
|
||||||
: value(v) { }
|
typedef T value_type;
|
||||||
|
A1() { }
|
||||||
int value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct A1 { };
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
|
||||||
struct A2 {
|
struct A2 {
|
||||||
void construct(S* p, int v) {
|
typedef T value_type;
|
||||||
new(p) S(v + 1);
|
A2() { }
|
||||||
|
template<class U, class V>
|
||||||
|
void construct(U* p, const V& v) {
|
||||||
|
::new((void*)p) U(v + 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
boost::default_allocator<S> d;
|
|
||||||
{
|
{
|
||||||
S* p = d.allocate(1);
|
A1<int> a;
|
||||||
A1 a;
|
int i = 0;
|
||||||
boost::allocator_construct(a, p, 1);
|
boost::allocator_construct(a, &i, 5);
|
||||||
BOOST_TEST_EQ(p->value, 1);
|
BOOST_TEST_EQ(i, 5);
|
||||||
d.deallocate(p, 1);
|
|
||||||
}
|
}
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
{
|
{
|
||||||
S* p = d.allocate(1);
|
A1<int> a;
|
||||||
A2 a;
|
int i = 0;
|
||||||
boost::allocator_construct(a, p, 1);
|
boost::allocator_construct(a, &i, 5);
|
||||||
BOOST_TEST_EQ(p->value, 2);
|
BOOST_TEST_EQ(i, 6);
|
||||||
d.deallocate(p, 1);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
|
@ -8,23 +8,22 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A {
|
struct A {
|
||||||
typedef int* pointer;
|
typedef T value_type;
|
||||||
typedef int size_type;
|
typedef T* pointer;
|
||||||
|
typedef std::size_t size_type;
|
||||||
A()
|
A()
|
||||||
: value() { }
|
: value() { }
|
||||||
|
void deallocate(T*, std::size_t n) {
|
||||||
void deallocate(pointer, size_type n) {
|
|
||||||
value = n;
|
value = n;
|
||||||
}
|
}
|
||||||
|
std::size_t value;
|
||||||
size_type value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
A a;
|
A<int> a;
|
||||||
boost::allocator_deallocate(a, 0, 5);
|
boost::allocator_deallocate(a, 0, 5);
|
||||||
BOOST_TEST_EQ(a.value, 5);
|
BOOST_TEST_EQ(a.value, 5);
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
|
@ -6,20 +6,16 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
(http://www.boost.org/LICENSE_1_0.txt)
|
(http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
#include <boost/core/default_allocator.hpp>
|
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
struct S {
|
struct S {
|
||||||
static int count;
|
static int count;
|
||||||
|
|
||||||
S() {
|
S() {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
S(const S&) {
|
S(const S&) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
~S() {
|
~S() {
|
||||||
--count;
|
--count;
|
||||||
}
|
}
|
||||||
@ -27,35 +23,39 @@ struct S {
|
|||||||
|
|
||||||
int S::count = 0;
|
int S::count = 0;
|
||||||
|
|
||||||
struct A1 { };
|
template<class T>
|
||||||
|
struct A1 {
|
||||||
|
typedef T value_type;
|
||||||
|
A1() { }
|
||||||
|
};
|
||||||
|
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
void destroy(S*) {
|
typedef T value_type;
|
||||||
++S::count;
|
A2() { }
|
||||||
|
template<class U>
|
||||||
|
void destroy(U* p) {
|
||||||
|
*p = U();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
boost::default_allocator<S> d;
|
|
||||||
{
|
{
|
||||||
S* p = d.allocate(1);
|
A1<int> a;
|
||||||
new(p) S;
|
S s;
|
||||||
A1 a;
|
boost::allocator_destroy(a, &s);
|
||||||
boost::allocator_destroy(a, p);
|
|
||||||
BOOST_TEST_EQ(S::count, 0);
|
BOOST_TEST_EQ(S::count, 0);
|
||||||
d.deallocate(p, 1);
|
::new((void*)&s) S();
|
||||||
}
|
}
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
{
|
{
|
||||||
S* p = d.allocate(1);
|
A1<int> a;
|
||||||
new(p) S;
|
int i = 5;
|
||||||
A2 a;
|
boost::allocator_destroy(a, &i);
|
||||||
boost::allocator_destroy(a, p);
|
BOOST_TEST_EQ(i, 0);
|
||||||
BOOST_TEST_EQ(S::count, 2);
|
|
||||||
d.deallocate(p, 1);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
|
@ -9,20 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
typedef char* pointer;
|
typedef T value_type;
|
||||||
|
typedef short difference_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
typedef char* pointer;
|
typedef T value_type;
|
||||||
typedef int difference_type;
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<short,
|
||||||
|
boost::allocator_difference_type<A1<char> >::type>));
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||||
boost::allocator_difference_type<A1>::type>));
|
boost::allocator_difference_type<A2<int> >::type>));
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
#endif
|
||||||
boost::allocator_difference_type<A2>::type>));
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,28 +9,39 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
|
typedef T value_type;
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
struct is_always_equal {
|
typedef T value_type;
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct A3 {
|
||||||
|
typedef T value_type;
|
||||||
|
typedef std::false_type is_always_equal;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct A4 {
|
||||||
|
typedef T value_type;
|
||||||
|
typedef std::true_type is_always_equal;
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
|
||||||
struct A3 { };
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1>::type));
|
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1<int> >::type));
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A2>::type));
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A2<int> >::type));
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A3>::type));
|
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A3<int> >::type));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A4<int> >::type));
|
||||||
#endif
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -7,29 +7,33 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
*/
|
*/
|
||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
typedef long value_type;
|
typedef T value_type;
|
||||||
typedef short size_type;
|
typedef short size_type;
|
||||||
};
|
A1() { }
|
||||||
|
short max_size() const {
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
|
||||||
struct A2 {
|
|
||||||
typedef long value_type;
|
|
||||||
typedef short size_type;
|
|
||||||
|
|
||||||
size_type max_size() const {
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
|
struct A2 {
|
||||||
|
typedef T value_type;
|
||||||
|
typedef short size_type;
|
||||||
|
A2() { }
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_EQ(boost::allocator_max_size(A1()),
|
BOOST_TEST_EQ(boost::allocator_max_size(A1<int>()), 1);
|
||||||
std::numeric_limits<A1::size_type>::max() / sizeof(A1::value_type));
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
BOOST_TEST_LE(boost::allocator_max_size(A2<int>()),
|
||||||
BOOST_TEST_EQ(boost::allocator_max_size(A2()), 1);
|
(std::numeric_limits<short>::max)());
|
||||||
#endif
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
struct A1 { };
|
template<class T>
|
||||||
|
struct A1 {
|
||||||
|
typedef T value_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
struct propagate_on_container_copy_assignment {
|
typedef T value_type;
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
typedef std::true_type propagate_on_container_copy_assignment;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_FALSE((boost::
|
BOOST_TEST_TRAIT_FALSE((boost::
|
||||||
allocator_propagate_on_container_copy_assignment<A1>::type));
|
allocator_propagate_on_container_copy_assignment<A1<int> >::type));
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::
|
BOOST_TEST_TRAIT_TRUE((boost::
|
||||||
allocator_propagate_on_container_copy_assignment<A2>::type));
|
allocator_propagate_on_container_copy_assignment<A2<int> >::type));
|
||||||
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
struct A1 { };
|
template<class T>
|
||||||
|
struct A1 {
|
||||||
|
typedef T value_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
struct propagate_on_container_move_assignment {
|
typedef T value_type;
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
typedef std::true_type propagate_on_container_move_assignment;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_FALSE((boost::
|
BOOST_TEST_TRAIT_FALSE((boost::
|
||||||
allocator_propagate_on_container_move_assignment<A1>::type));
|
allocator_propagate_on_container_move_assignment<A1<int> >::type));
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::
|
BOOST_TEST_TRAIT_TRUE((boost::
|
||||||
allocator_propagate_on_container_move_assignment<A2>::type));
|
allocator_propagate_on_container_move_assignment<A2<int> >::type));
|
||||||
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
struct A1 { };
|
template<class T>
|
||||||
|
struct A1 {
|
||||||
|
typedef T value_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
struct propagate_on_container_swap {
|
typedef T value_type;
|
||||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
typedef std::true_type propagate_on_container_swap;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_FALSE((boost::
|
BOOST_TEST_TRAIT_FALSE((boost::
|
||||||
allocator_propagate_on_container_swap<A1>::type));
|
allocator_propagate_on_container_swap<A1<int> >::type));
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::
|
BOOST_TEST_TRAIT_TRUE((boost::
|
||||||
allocator_propagate_on_container_swap<A2>::type));
|
allocator_propagate_on_container_swap<A2<int> >::type));
|
||||||
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
typedef char value_type;
|
typedef T value_type;
|
||||||
};
|
|
||||||
|
|
||||||
struct A2 {
|
|
||||||
typedef char value_type;
|
|
||||||
typedef int* pointer;
|
typedef int* pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
|
struct A2 {
|
||||||
|
typedef T value_type;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
|
|
||||||
boost::allocator_pointer<A1>::type>));
|
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||||
boost::allocator_pointer<A2>::type>));
|
boost::allocator_pointer<A1<char> >::type>));
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||||
|
boost::allocator_pointer<A2<int> >::type>));
|
||||||
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,22 +9,29 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
template<class, class, class>
|
|
||||||
struct A1 { };
|
|
||||||
|
|
||||||
template<class, class U, class V>
|
|
||||||
struct A2 {
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
struct A1 {
|
||||||
|
typedef T value_type;
|
||||||
|
template<class>
|
||||||
struct rebind {
|
struct rebind {
|
||||||
typedef A1<T, U, V> other;
|
typedef A1<int> other;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
|
struct A2 {
|
||||||
|
typedef T value_type;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<bool, int, float>,
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<int>,
|
||||||
boost::allocator_rebind<A1<char, int, float>, bool>::type>));
|
boost::allocator_rebind<A1<char>, bool>::type>));
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<bool, int, float>,
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
boost::allocator_rebind<A2<char, int, float>, bool>::type>));
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A2<int>,
|
||||||
|
boost::allocator_rebind<A2<char>, int>::type>));
|
||||||
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,26 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
typedef long difference_type;
|
typedef T value_type;
|
||||||
|
typedef int size_type;
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
struct A1 {
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
typedef unsigned long size_type;
|
template<class T>
|
||||||
|
struct A2 {
|
||||||
|
typedef T value_type;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct A2 {
|
|
||||||
typedef long difference_type;
|
|
||||||
typedef unsigned short size_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<unsigned long,
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||||
boost::allocator_size_type<A1>::type>));
|
boost::allocator_size_type<A1<char> >::type>));
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<unsigned short,
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
boost::allocator_size_type<A2>::type>));
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::size_t,
|
||||||
|
boost::allocator_size_type<A2<int> >::type>));
|
||||||
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -8,33 +8,34 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
A1(int v)
|
typedef T value_type;
|
||||||
: value(v) { }
|
A1(int n)
|
||||||
|
: value(n) { }
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
A2(int v)
|
typedef T value_type;
|
||||||
: value(v) { }
|
A2(int n)
|
||||||
|
: value(n) { }
|
||||||
A2 select_on_container_copy_construction() const {
|
A2 select_on_container_copy_construction() const {
|
||||||
return A2(value + 1);
|
return A2(value + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_EQ(1,
|
BOOST_TEST_EQ(1, boost::
|
||||||
boost::allocator_select_on_container_copy_construction(A1(1)).value);
|
allocator_select_on_container_copy_construction(A1<int>(1)).value);
|
||||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
BOOST_TEST_EQ(2,
|
BOOST_TEST_EQ(2, boost::
|
||||||
boost::allocator_select_on_container_copy_construction(A2(1)).value);
|
allocator_select_on_container_copy_construction(A2<int>(1)).value);
|
||||||
#endif
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,14 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A {
|
struct A {
|
||||||
typedef int value_type;
|
typedef T value_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||||
boost::allocator_value_type<A>::type>));
|
boost::allocator_value_type<A<int> >::type>));
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,31 @@ Distributed under the Boost Software License, Version 1.0.
|
|||||||
#include <boost/core/is_same.hpp>
|
#include <boost/core/is_same.hpp>
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
struct A1 {
|
struct A1 {
|
||||||
|
typedef T value_type;
|
||||||
typedef int* pointer;
|
typedef int* pointer;
|
||||||
|
typedef int* void_pointer;
|
||||||
|
template<class U>
|
||||||
|
struct rebind {
|
||||||
|
typedef A1<U> other;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
template<class T>
|
||||||
struct A2 {
|
struct A2 {
|
||||||
typedef int* pointer;
|
typedef T value_type;
|
||||||
typedef bool* void_pointer;
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||||
|
boost::allocator_void_pointer<A1<char> >::type>));
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||||
boost::allocator_void_pointer<A1>::type>));
|
boost::allocator_void_pointer<A2<int> >::type>));
|
||||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool*,
|
#endif
|
||||||
boost::allocator_void_pointer<A2>::type>));
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user