25 #ifndef _USES_ALLOCATOR_H 26 #define _USES_ALLOCATOR_H 1 28 #if __cplusplus < 201103L 35 namespace std _GLIBCXX_VISIBILITY(default)
37 _GLIBCXX_BEGIN_NAMESPACE_VERSION
39 struct __erased_type { };
41 template<
typename _Alloc,
typename _Tp>
42 using __is_erased_or_convertible
43 = __or_<is_same<_Tp, __erased_type>, is_convertible<_Alloc, _Tp>>;
50 template<
typename _Tp,
typename _Alloc,
typename = __
void_t<>>
51 struct __uses_allocator_helper
54 template<
typename _Tp,
typename _Alloc>
55 struct __uses_allocator_helper<_Tp, _Alloc,
56 __void_t<typename _Tp::allocator_type>>
57 : __is_erased_or_convertible<_Alloc, typename _Tp::allocator_type>::type
61 template<
typename _Tp,
typename _Alloc>
63 : __uses_allocator_helper<_Tp, _Alloc>::type
66 struct __uses_alloc_base { };
68 struct __uses_alloc0 : __uses_alloc_base
70 struct _Sink {
void operator=(
const void*) { } } _M_a;
73 template<
typename _Alloc>
74 struct __uses_alloc1 : __uses_alloc_base {
const _Alloc* _M_a; };
76 template<
typename _Alloc>
77 struct __uses_alloc2 : __uses_alloc_base {
const _Alloc* _M_a; };
79 template<bool,
typename _Tp,
typename _Alloc,
typename... _Args>
82 template<
typename _Tp,
typename _Alloc,
typename... _Args>
83 struct __uses_alloc<true, _Tp, _Alloc, _Args...>
85 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value,
86 __uses_alloc1<_Alloc>,
87 __uses_alloc2<_Alloc>>::type
90 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>,
91 is_constructible<_Tp, _Args..., _Alloc>>::value,
"construction with" 92 " an allocator must be possible if uses_allocator is true");
95 template<
typename _Tp,
typename _Alloc,
typename... _Args>
96 struct __uses_alloc<false, _Tp, _Alloc, _Args...>
99 template<
typename _Tp,
typename _Alloc,
typename... _Args>
100 using __uses_alloc_t =
101 __uses_alloc<uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args...>;
103 template<
typename _Tp,
typename _Alloc,
typename... _Args>
104 inline __uses_alloc_t<_Tp, _Alloc, _Args...>
105 __use_alloc(
const _Alloc& __a)
107 __uses_alloc_t<_Tp, _Alloc, _Args...> __ret;
112 _GLIBCXX_END_NAMESPACE_VERSION
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
ISO C++ entities toplevel namespace is std.
Declare uses_allocator so it can be specialized in <queue> etc.