mirror of
https://github.com/boostorg/core.git
synced 2025-05-09 23:03:54 +00:00
Use same style of detection in pointer_traits and allocator_traits
This commit is contained in:
parent
a2b37091eb
commit
02b3f91fc3
@ -386,22 +386,24 @@ allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
|||||||
#else
|
#else
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
struct alloc_none { };
|
template<class>
|
||||||
|
struct alloc_no {
|
||||||
|
char x, y;
|
||||||
|
};
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
class alloc_has_allocate {
|
class alloc_has_allocate {
|
||||||
template<class O>
|
template<class O>
|
||||||
static auto check(int)
|
static auto check(int)
|
||||||
-> decltype(std::declval<O&>().allocate(std::declval<typename
|
-> alloc_no<decltype(std::declval<O&>().allocate(std::declval<typename
|
||||||
boost::allocator_size_type<A>::type>(), std::declval<typename
|
boost::allocator_size_type<A>::type>(), std::declval<typename
|
||||||
boost::allocator_const_void_pointer<A>::type>()));
|
boost::allocator_const_void_pointer<A>::type>()))>;
|
||||||
|
|
||||||
template<class>
|
template<class>
|
||||||
static alloc_none check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOST_STATIC_CONSTEXPR bool value =
|
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* detail */
|
} /* detail */
|
||||||
@ -471,15 +473,14 @@ template<class A, class T, class... Args>
|
|||||||
class alloc_has_construct {
|
class alloc_has_construct {
|
||||||
template<class O>
|
template<class O>
|
||||||
static auto check(int)
|
static auto check(int)
|
||||||
-> decltype(std::declval<O&>().construct(std::declval<T*>(),
|
-> alloc_no<decltype(std::declval<O&>().construct(std::declval<T*>(),
|
||||||
std::declval<Args&&>()...));
|
std::declval<Args&&>()...))>;
|
||||||
|
|
||||||
template<class>
|
template<class>
|
||||||
static alloc_none check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOST_STATIC_CONSTEXPR bool value =
|
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* detail */
|
} /* detail */
|
||||||
@ -516,14 +517,13 @@ template<class A, class T>
|
|||||||
class alloc_has_destroy {
|
class alloc_has_destroy {
|
||||||
template<class O>
|
template<class O>
|
||||||
static auto check(int)
|
static auto check(int)
|
||||||
-> decltype(std::declval<O&>().destroy(std::declval<T*>()));
|
-> alloc_no<decltype(std::declval<O&>().destroy(std::declval<T*>()))>;
|
||||||
|
|
||||||
template<class>
|
template<class>
|
||||||
static alloc_none check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOST_STATIC_CONSTEXPR bool value =
|
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* detail */
|
} /* detail */
|
||||||
@ -549,8 +549,7 @@ namespace detail {
|
|||||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
template<class T, T>
|
template<class T, T>
|
||||||
struct alloc_no {
|
struct alloc_no {
|
||||||
char x;
|
char x, y;
|
||||||
char y;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
@ -571,20 +570,20 @@ class alloc_has_max_size {
|
|||||||
static char check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) != 1;
|
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
template<class A>
|
template<class A>
|
||||||
class alloc_has_max_size {
|
class alloc_has_max_size {
|
||||||
template<class O>
|
template<class O>
|
||||||
static auto check(int) -> decltype(std::declval<const O&>().max_size());
|
static auto check(int)
|
||||||
|
-> alloc_no<decltype(std::declval<const O&>().max_size())>;
|
||||||
|
|
||||||
template<class>
|
template<class>
|
||||||
static alloc_none check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOST_STATIC_CONSTEXPR bool value =
|
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -637,21 +636,20 @@ class alloc_has_soccc {
|
|||||||
static char check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) != 1;
|
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
template<class A>
|
template<class A>
|
||||||
class alloc_has_soccc {
|
class alloc_has_soccc {
|
||||||
template<class O>
|
template<class O>
|
||||||
static auto check(int) -> decltype(std::declval<const
|
static auto check(int) -> alloc_no<decltype(std::declval<const
|
||||||
O&>().select_on_container_copy_construction());
|
O&>().select_on_container_copy_construction())>;
|
||||||
|
|
||||||
template<class>
|
template<class>
|
||||||
static alloc_none check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOST_STATIC_CONSTEXPR bool value =
|
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class ptr_to_expr {
|
|||||||
static char check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<T>(0)) != 1;
|
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<T>(0)) > 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T, class E>
|
template<class T, class E>
|
||||||
|
@ -24,7 +24,7 @@ class has_pointer_to {
|
|||||||
static char check(long);
|
static char check(long);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const bool value = sizeof(check<T>(0)) != 1;
|
static const bool value = sizeof(check<T>(0)) > 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct P1 { };
|
struct P1 { };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user