25 #ifndef _USES_ALLOCATOR_H
26 #define _USES_ALLOCATOR_H 1
28 #if __cplusplus < 201103L
32 #include <type_traits>
36 _GLIBCXX_BEGIN_NAMESPACE_VERSION
39 struct allocator_arg_t { };
41 constexpr allocator_arg_t allocator_arg = allocator_arg_t();
43 _GLIBCXX_HAS_NESTED_TYPE(allocator_type)
45 template<typename _Tp, typename _Alloc,
46 bool = __has_allocator_type<_Tp>::value>
47 struct __uses_allocator_helper
50 template<
typename _Tp,
typename _Alloc>
51 struct __uses_allocator_helper<_Tp, _Alloc,
true>
52 :
public integral_constant<bool, is_convertible<_Alloc,
53 typename _Tp::allocator_type>::value>
57 template<
typename _Tp,
typename _Alloc>
59 :
public integral_constant<bool,
60 __uses_allocator_helper<_Tp, _Alloc>::value>
63 template<
typename _Tp,
typename _Alloc,
typename... _Args>
64 struct __uses_allocator_arg
65 : is_constructible<_Tp, _Alloc, _Args...>
66 { static_assert( uses_allocator<_Tp, _Alloc>::value,
"uses allocator" ); };
68 struct __uses_alloc_base { };
69 struct __uses_alloc0 : __uses_alloc_base
70 {
struct _Anything { _Anything(...) { } } _M_a; };
71 template<
typename _Alloc>
72 struct __uses_alloc1 : __uses_alloc_base {
const _Alloc* _M_a; };
73 template<
typename _Alloc>
74 struct __uses_alloc2 : __uses_alloc_base {
const _Alloc* _M_a; };
76 template<
bool,
typename _Alloc,
typename... _Args>
79 template<
typename _Tp,
typename _Alloc,
typename... _Args>
80 struct __uses_alloc<
true, _Tp, _Alloc, _Args...>
82 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value,
83 __uses_alloc1<_Alloc>,
84 __uses_alloc2<_Alloc>>::type
87 template<
typename _Tp,
typename _Alloc,
typename... _Args>
88 struct __uses_alloc<
false, _Tp, _Alloc, _Args...>
91 template<
typename _Tp,
typename _Alloc,
typename... _Args>
92 struct __uses_alloc_impl
93 : __uses_alloc<uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args...>
96 template<
typename _Tp,
typename _Alloc,
typename... _Args>
97 __uses_alloc_impl<_Tp, _Alloc, _Args...>
98 __use_alloc(
const _Alloc& __a)
100 __uses_alloc_impl<_Tp, _Alloc, _Args...> __ret;
105 _GLIBCXX_END_NAMESPACE_VERSION
#define false
Definition: stdbool.h:35
#define true
Definition: stdbool.h:34
#define bool
Definition: stdbool.h:33
namespace std _GLIBCXX_VISIBILITY(default)
Definition: auto_ptr.h:36
std::tr1::integral_constant< int, 0 > false_type
Definition: type_utils.hpp:71