annotate libcxx/include/scoped_allocator @ 220:42394fc6a535

Added tag llvm12 for changeset 0572611fdcc8
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:13:43 +0900
parents 1d019706d866
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // -*- C++ -*-
anatofuz
parents:
diff changeset
2 //===-------------------------- scoped_allocator --------------------------===//
anatofuz
parents:
diff changeset
3 //
anatofuz
parents:
diff changeset
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
5 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
7 //
anatofuz
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 #ifndef _LIBCPP_SCOPED_ALLOCATOR
anatofuz
parents:
diff changeset
11 #define _LIBCPP_SCOPED_ALLOCATOR
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 /*
anatofuz
parents:
diff changeset
14 scoped_allocator synopsis
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 namespace std
anatofuz
parents:
diff changeset
17 {
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 template <class OuterAlloc, class... InnerAllocs>
anatofuz
parents:
diff changeset
20 class scoped_allocator_adaptor : public OuterAlloc
anatofuz
parents:
diff changeset
21 {
anatofuz
parents:
diff changeset
22 typedef allocator_traits<OuterAlloc> OuterTraits; // exposition only
anatofuz
parents:
diff changeset
23 scoped_allocator_adaptor<InnerAllocs...> inner; // exposition only
anatofuz
parents:
diff changeset
24 public:
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 typedef OuterAlloc outer_allocator_type;
anatofuz
parents:
diff changeset
27 typedef see below inner_allocator_type;
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 typedef typename OuterTraits::value_type value_type;
anatofuz
parents:
diff changeset
30 typedef typename OuterTraits::size_type size_type;
anatofuz
parents:
diff changeset
31 typedef typename OuterTraits::difference_type difference_type;
anatofuz
parents:
diff changeset
32 typedef typename OuterTraits::pointer pointer;
anatofuz
parents:
diff changeset
33 typedef typename OuterTraits::const_pointer const_pointer;
anatofuz
parents:
diff changeset
34 typedef typename OuterTraits::void_pointer void_pointer;
anatofuz
parents:
diff changeset
35 typedef typename OuterTraits::const_void_pointer const_void_pointer;
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 typedef see below propagate_on_container_copy_assignment;
anatofuz
parents:
diff changeset
38 typedef see below propagate_on_container_move_assignment;
anatofuz
parents:
diff changeset
39 typedef see below propagate_on_container_swap;
anatofuz
parents:
diff changeset
40 typedef see below is_always_equal;
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 template <class Tp>
anatofuz
parents:
diff changeset
43 struct rebind
anatofuz
parents:
diff changeset
44 {
anatofuz
parents:
diff changeset
45 typedef scoped_allocator_adaptor<
anatofuz
parents:
diff changeset
46 OuterTraits::template rebind_alloc<Tp>, InnerAllocs...> other;
anatofuz
parents:
diff changeset
47 };
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 scoped_allocator_adaptor();
anatofuz
parents:
diff changeset
50 template <class OuterA2>
anatofuz
parents:
diff changeset
51 scoped_allocator_adaptor(OuterA2&& outerAlloc,
anatofuz
parents:
diff changeset
52 const InnerAllocs&... innerAllocs) noexcept;
anatofuz
parents:
diff changeset
53 scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept;
anatofuz
parents:
diff changeset
54 scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept;
anatofuz
parents:
diff changeset
55 template <class OuterA2>
anatofuz
parents:
diff changeset
56 scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept;
anatofuz
parents:
diff changeset
57 template <class OuterA2>
anatofuz
parents:
diff changeset
58 scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
anatofuz
parents:
diff changeset
59
anatofuz
parents:
diff changeset
60 scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
anatofuz
parents:
diff changeset
61 scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
anatofuz
parents:
diff changeset
62 ~scoped_allocator_adaptor();
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 inner_allocator_type& inner_allocator() noexcept;
anatofuz
parents:
diff changeset
65 const inner_allocator_type& inner_allocator() const noexcept;
anatofuz
parents:
diff changeset
66
anatofuz
parents:
diff changeset
67 outer_allocator_type& outer_allocator() noexcept;
anatofuz
parents:
diff changeset
68 const outer_allocator_type& outer_allocator() const noexcept;
anatofuz
parents:
diff changeset
69
anatofuz
parents:
diff changeset
70 pointer allocate(size_type n); // [[nodiscard]] in C++20
anatofuz
parents:
diff changeset
71 pointer allocate(size_type n, const_void_pointer hint); // [[nodiscard]] in C++20
anatofuz
parents:
diff changeset
72 void deallocate(pointer p, size_type n) noexcept;
anatofuz
parents:
diff changeset
73
anatofuz
parents:
diff changeset
74 size_type max_size() const;
anatofuz
parents:
diff changeset
75 template <class T, class... Args> void construct(T* p, Args&& args);
anatofuz
parents:
diff changeset
76 template <class T1, class T2, class... Args1, class... Args2>
anatofuz
parents:
diff changeset
77 void construct(pair<T1, T2>* p, piecewise_construct t, tuple<Args1...> x,
anatofuz
parents:
diff changeset
78 tuple<Args2...> y);
anatofuz
parents:
diff changeset
79 template <class T1, class T2>
anatofuz
parents:
diff changeset
80 void construct(pair<T1, T2>* p);
anatofuz
parents:
diff changeset
81 template <class T1, class T2, class U, class V>
anatofuz
parents:
diff changeset
82 void construct(pair<T1, T2>* p, U&& x, V&& y);
anatofuz
parents:
diff changeset
83 template <class T1, class T2, class U, class V>
anatofuz
parents:
diff changeset
84 void construct(pair<T1, T2>* p, const pair<U, V>& x);
anatofuz
parents:
diff changeset
85 template <class T1, class T2, class U, class V>
anatofuz
parents:
diff changeset
86 void construct(pair<T1, T2>* p, pair<U, V>&& x);
anatofuz
parents:
diff changeset
87 template <class T> void destroy(T* p);
anatofuz
parents:
diff changeset
88
anatofuz
parents:
diff changeset
89 template <class T> void destroy(T* p) noexcept;
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 scoped_allocator_adaptor select_on_container_copy_construction() const noexcept;
anatofuz
parents:
diff changeset
92 };
anatofuz
parents:
diff changeset
93
anatofuz
parents:
diff changeset
94 template <class OuterA1, class OuterA2, class... InnerAllocs>
anatofuz
parents:
diff changeset
95 bool
anatofuz
parents:
diff changeset
96 operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
anatofuz
parents:
diff changeset
97 const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
anatofuz
parents:
diff changeset
98
anatofuz
parents:
diff changeset
99 template <class OuterA1, class OuterA2, class... InnerAllocs>
anatofuz
parents:
diff changeset
100 bool
anatofuz
parents:
diff changeset
101 operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
anatofuz
parents:
diff changeset
102 const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
anatofuz
parents:
diff changeset
103
anatofuz
parents:
diff changeset
104 } // std
anatofuz
parents:
diff changeset
105
anatofuz
parents:
diff changeset
106 */
anatofuz
parents:
diff changeset
107
anatofuz
parents:
diff changeset
108 #include <__config>
anatofuz
parents:
diff changeset
109 #include <memory>
anatofuz
parents:
diff changeset
110 #include <version>
anatofuz
parents:
diff changeset
111
anatofuz
parents:
diff changeset
112 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
anatofuz
parents:
diff changeset
113 #pragma GCC system_header
anatofuz
parents:
diff changeset
114 #endif
anatofuz
parents:
diff changeset
115
anatofuz
parents:
diff changeset
116 _LIBCPP_BEGIN_NAMESPACE_STD
anatofuz
parents:
diff changeset
117
anatofuz
parents:
diff changeset
118 #if !defined(_LIBCPP_CXX03_LANG)
anatofuz
parents:
diff changeset
119
anatofuz
parents:
diff changeset
120 // scoped_allocator_adaptor
anatofuz
parents:
diff changeset
121
anatofuz
parents:
diff changeset
122 template <class ..._Allocs>
anatofuz
parents:
diff changeset
123 class scoped_allocator_adaptor;
anatofuz
parents:
diff changeset
124
anatofuz
parents:
diff changeset
125 template <class ..._Allocs> struct __get_poc_copy_assignment;
anatofuz
parents:
diff changeset
126
anatofuz
parents:
diff changeset
127 template <class _A0>
anatofuz
parents:
diff changeset
128 struct __get_poc_copy_assignment<_A0>
anatofuz
parents:
diff changeset
129 {
anatofuz
parents:
diff changeset
130 static const bool value = allocator_traits<_A0>::
anatofuz
parents:
diff changeset
131 propagate_on_container_copy_assignment::value;
anatofuz
parents:
diff changeset
132 };
anatofuz
parents:
diff changeset
133
anatofuz
parents:
diff changeset
134 template <class _A0, class ..._Allocs>
anatofuz
parents:
diff changeset
135 struct __get_poc_copy_assignment<_A0, _Allocs...>
anatofuz
parents:
diff changeset
136 {
anatofuz
parents:
diff changeset
137 static const bool value =
anatofuz
parents:
diff changeset
138 allocator_traits<_A0>::propagate_on_container_copy_assignment::value ||
anatofuz
parents:
diff changeset
139 __get_poc_copy_assignment<_Allocs...>::value;
anatofuz
parents:
diff changeset
140 };
anatofuz
parents:
diff changeset
141
anatofuz
parents:
diff changeset
142 template <class ..._Allocs> struct __get_poc_move_assignment;
anatofuz
parents:
diff changeset
143
anatofuz
parents:
diff changeset
144 template <class _A0>
anatofuz
parents:
diff changeset
145 struct __get_poc_move_assignment<_A0>
anatofuz
parents:
diff changeset
146 {
anatofuz
parents:
diff changeset
147 static const bool value = allocator_traits<_A0>::
anatofuz
parents:
diff changeset
148 propagate_on_container_move_assignment::value;
anatofuz
parents:
diff changeset
149 };
anatofuz
parents:
diff changeset
150
anatofuz
parents:
diff changeset
151 template <class _A0, class ..._Allocs>
anatofuz
parents:
diff changeset
152 struct __get_poc_move_assignment<_A0, _Allocs...>
anatofuz
parents:
diff changeset
153 {
anatofuz
parents:
diff changeset
154 static const bool value =
anatofuz
parents:
diff changeset
155 allocator_traits<_A0>::propagate_on_container_move_assignment::value ||
anatofuz
parents:
diff changeset
156 __get_poc_move_assignment<_Allocs...>::value;
anatofuz
parents:
diff changeset
157 };
anatofuz
parents:
diff changeset
158
anatofuz
parents:
diff changeset
159 template <class ..._Allocs> struct __get_poc_swap;
anatofuz
parents:
diff changeset
160
anatofuz
parents:
diff changeset
161 template <class _A0>
anatofuz
parents:
diff changeset
162 struct __get_poc_swap<_A0>
anatofuz
parents:
diff changeset
163 {
anatofuz
parents:
diff changeset
164 static const bool value = allocator_traits<_A0>::
anatofuz
parents:
diff changeset
165 propagate_on_container_swap::value;
anatofuz
parents:
diff changeset
166 };
anatofuz
parents:
diff changeset
167
anatofuz
parents:
diff changeset
168 template <class _A0, class ..._Allocs>
anatofuz
parents:
diff changeset
169 struct __get_poc_swap<_A0, _Allocs...>
anatofuz
parents:
diff changeset
170 {
anatofuz
parents:
diff changeset
171 static const bool value =
anatofuz
parents:
diff changeset
172 allocator_traits<_A0>::propagate_on_container_swap::value ||
anatofuz
parents:
diff changeset
173 __get_poc_swap<_Allocs...>::value;
anatofuz
parents:
diff changeset
174 };
anatofuz
parents:
diff changeset
175
anatofuz
parents:
diff changeset
176 template <class ..._Allocs> struct __get_is_always_equal;
anatofuz
parents:
diff changeset
177
anatofuz
parents:
diff changeset
178 template <class _A0>
anatofuz
parents:
diff changeset
179 struct __get_is_always_equal<_A0>
anatofuz
parents:
diff changeset
180 {
anatofuz
parents:
diff changeset
181 static const bool value = allocator_traits<_A0>::is_always_equal::value;
anatofuz
parents:
diff changeset
182 };
anatofuz
parents:
diff changeset
183
anatofuz
parents:
diff changeset
184 template <class _A0, class ..._Allocs>
anatofuz
parents:
diff changeset
185 struct __get_is_always_equal<_A0, _Allocs...>
anatofuz
parents:
diff changeset
186 {
anatofuz
parents:
diff changeset
187 static const bool value =
anatofuz
parents:
diff changeset
188 allocator_traits<_A0>::is_always_equal::value &&
anatofuz
parents:
diff changeset
189 __get_is_always_equal<_Allocs...>::value;
anatofuz
parents:
diff changeset
190 };
anatofuz
parents:
diff changeset
191
anatofuz
parents:
diff changeset
192 template <class ..._Allocs>
anatofuz
parents:
diff changeset
193 class __scoped_allocator_storage;
anatofuz
parents:
diff changeset
194
anatofuz
parents:
diff changeset
195 template <class _OuterAlloc, class... _InnerAllocs>
anatofuz
parents:
diff changeset
196 class __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
anatofuz
parents:
diff changeset
197 : public _OuterAlloc
anatofuz
parents:
diff changeset
198 {
anatofuz
parents:
diff changeset
199 typedef _OuterAlloc outer_allocator_type;
anatofuz
parents:
diff changeset
200 protected:
anatofuz
parents:
diff changeset
201 typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type;
anatofuz
parents:
diff changeset
202
anatofuz
parents:
diff changeset
203 private:
anatofuz
parents:
diff changeset
204 inner_allocator_type __inner_;
anatofuz
parents:
diff changeset
205
anatofuz
parents:
diff changeset
206 protected:
anatofuz
parents:
diff changeset
207
anatofuz
parents:
diff changeset
208 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
209 __scoped_allocator_storage() _NOEXCEPT {}
anatofuz
parents:
diff changeset
210
anatofuz
parents:
diff changeset
211 template <class _OuterA2,
anatofuz
parents:
diff changeset
212 class = typename enable_if<
anatofuz
parents:
diff changeset
213 is_constructible<outer_allocator_type, _OuterA2>::value
anatofuz
parents:
diff changeset
214 >::type>
anatofuz
parents:
diff changeset
215 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
216 __scoped_allocator_storage(_OuterA2&& __outerAlloc,
anatofuz
parents:
diff changeset
217 const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
anatofuz
parents:
diff changeset
218 : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)),
anatofuz
parents:
diff changeset
219 __inner_(__innerAllocs...) {}
anatofuz
parents:
diff changeset
220
anatofuz
parents:
diff changeset
221 template <class _OuterA2,
anatofuz
parents:
diff changeset
222 class = typename enable_if<
anatofuz
parents:
diff changeset
223 is_constructible<outer_allocator_type, const _OuterA2&>::value
anatofuz
parents:
diff changeset
224 >::type>
anatofuz
parents:
diff changeset
225 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
226 __scoped_allocator_storage(
anatofuz
parents:
diff changeset
227 const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
anatofuz
parents:
diff changeset
228 : outer_allocator_type(__other.outer_allocator()),
anatofuz
parents:
diff changeset
229 __inner_(__other.inner_allocator()) {}
anatofuz
parents:
diff changeset
230
anatofuz
parents:
diff changeset
231 template <class _OuterA2,
anatofuz
parents:
diff changeset
232 class = typename enable_if<
anatofuz
parents:
diff changeset
233 is_constructible<outer_allocator_type, _OuterA2>::value
anatofuz
parents:
diff changeset
234 >::type>
anatofuz
parents:
diff changeset
235 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
236 __scoped_allocator_storage(
anatofuz
parents:
diff changeset
237 __scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
anatofuz
parents:
diff changeset
238 : outer_allocator_type(_VSTD::move(__other.outer_allocator())),
anatofuz
parents:
diff changeset
239 __inner_(_VSTD::move(__other.inner_allocator())) {}
anatofuz
parents:
diff changeset
240
anatofuz
parents:
diff changeset
241 template <class _OuterA2,
anatofuz
parents:
diff changeset
242 class = typename enable_if<
anatofuz
parents:
diff changeset
243 is_constructible<outer_allocator_type, _OuterA2>::value
anatofuz
parents:
diff changeset
244 >::type>
anatofuz
parents:
diff changeset
245 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
246 __scoped_allocator_storage(_OuterA2&& __o,
anatofuz
parents:
diff changeset
247 const inner_allocator_type& __i) _NOEXCEPT
anatofuz
parents:
diff changeset
248 : outer_allocator_type(_VSTD::forward<_OuterA2>(__o)),
anatofuz
parents:
diff changeset
249 __inner_(__i)
anatofuz
parents:
diff changeset
250 {
anatofuz
parents:
diff changeset
251 }
anatofuz
parents:
diff changeset
252
anatofuz
parents:
diff changeset
253 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
254 inner_allocator_type& inner_allocator() _NOEXCEPT {return __inner_;}
anatofuz
parents:
diff changeset
255 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
256 const inner_allocator_type& inner_allocator() const _NOEXCEPT {return __inner_;}
anatofuz
parents:
diff changeset
257
anatofuz
parents:
diff changeset
258 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
259 outer_allocator_type& outer_allocator() _NOEXCEPT
anatofuz
parents:
diff changeset
260 {return static_cast<outer_allocator_type&>(*this);}
anatofuz
parents:
diff changeset
261 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
262 const outer_allocator_type& outer_allocator() const _NOEXCEPT
anatofuz
parents:
diff changeset
263 {return static_cast<const outer_allocator_type&>(*this);}
anatofuz
parents:
diff changeset
264
anatofuz
parents:
diff changeset
265 scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>
anatofuz
parents:
diff changeset
266 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
267 select_on_container_copy_construction() const _NOEXCEPT
anatofuz
parents:
diff changeset
268 {
anatofuz
parents:
diff changeset
269 return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>
anatofuz
parents:
diff changeset
270 (
anatofuz
parents:
diff changeset
271 allocator_traits<outer_allocator_type>::
anatofuz
parents:
diff changeset
272 select_on_container_copy_construction(outer_allocator()),
anatofuz
parents:
diff changeset
273 allocator_traits<inner_allocator_type>::
anatofuz
parents:
diff changeset
274 select_on_container_copy_construction(inner_allocator())
anatofuz
parents:
diff changeset
275 );
anatofuz
parents:
diff changeset
276 }
anatofuz
parents:
diff changeset
277
anatofuz
parents:
diff changeset
278 template <class...> friend class __scoped_allocator_storage;
anatofuz
parents:
diff changeset
279 };
anatofuz
parents:
diff changeset
280
anatofuz
parents:
diff changeset
281 template <class _OuterAlloc>
anatofuz
parents:
diff changeset
282 class __scoped_allocator_storage<_OuterAlloc>
anatofuz
parents:
diff changeset
283 : public _OuterAlloc
anatofuz
parents:
diff changeset
284 {
anatofuz
parents:
diff changeset
285 typedef _OuterAlloc outer_allocator_type;
anatofuz
parents:
diff changeset
286 protected:
anatofuz
parents:
diff changeset
287 typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type;
anatofuz
parents:
diff changeset
288
anatofuz
parents:
diff changeset
289 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
290 __scoped_allocator_storage() _NOEXCEPT {}
anatofuz
parents:
diff changeset
291
anatofuz
parents:
diff changeset
292 template <class _OuterA2,
anatofuz
parents:
diff changeset
293 class = typename enable_if<
anatofuz
parents:
diff changeset
294 is_constructible<outer_allocator_type, _OuterA2>::value
anatofuz
parents:
diff changeset
295 >::type>
anatofuz
parents:
diff changeset
296 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
297 __scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT
anatofuz
parents:
diff changeset
298 : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {}
anatofuz
parents:
diff changeset
299
anatofuz
parents:
diff changeset
300 template <class _OuterA2,
anatofuz
parents:
diff changeset
301 class = typename enable_if<
anatofuz
parents:
diff changeset
302 is_constructible<outer_allocator_type, const _OuterA2&>::value
anatofuz
parents:
diff changeset
303 >::type>
anatofuz
parents:
diff changeset
304 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
305 __scoped_allocator_storage(
anatofuz
parents:
diff changeset
306 const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT
anatofuz
parents:
diff changeset
307 : outer_allocator_type(__other.outer_allocator()) {}
anatofuz
parents:
diff changeset
308
anatofuz
parents:
diff changeset
309 template <class _OuterA2,
anatofuz
parents:
diff changeset
310 class = typename enable_if<
anatofuz
parents:
diff changeset
311 is_constructible<outer_allocator_type, _OuterA2>::value
anatofuz
parents:
diff changeset
312 >::type>
anatofuz
parents:
diff changeset
313 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
314 __scoped_allocator_storage(
anatofuz
parents:
diff changeset
315 __scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT
anatofuz
parents:
diff changeset
316 : outer_allocator_type(_VSTD::move(__other.outer_allocator())) {}
anatofuz
parents:
diff changeset
317
anatofuz
parents:
diff changeset
318 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
319 inner_allocator_type& inner_allocator() _NOEXCEPT
anatofuz
parents:
diff changeset
320 {return static_cast<inner_allocator_type&>(*this);}
anatofuz
parents:
diff changeset
321 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
322 const inner_allocator_type& inner_allocator() const _NOEXCEPT
anatofuz
parents:
diff changeset
323 {return static_cast<const inner_allocator_type&>(*this);}
anatofuz
parents:
diff changeset
324
anatofuz
parents:
diff changeset
325 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
326 outer_allocator_type& outer_allocator() _NOEXCEPT
anatofuz
parents:
diff changeset
327 {return static_cast<outer_allocator_type&>(*this);}
anatofuz
parents:
diff changeset
328 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
329 const outer_allocator_type& outer_allocator() const _NOEXCEPT
anatofuz
parents:
diff changeset
330 {return static_cast<const outer_allocator_type&>(*this);}
anatofuz
parents:
diff changeset
331
anatofuz
parents:
diff changeset
332 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
333 scoped_allocator_adaptor<outer_allocator_type>
anatofuz
parents:
diff changeset
334 select_on_container_copy_construction() const _NOEXCEPT
anatofuz
parents:
diff changeset
335 {return scoped_allocator_adaptor<outer_allocator_type>(
anatofuz
parents:
diff changeset
336 allocator_traits<outer_allocator_type>::
anatofuz
parents:
diff changeset
337 select_on_container_copy_construction(outer_allocator())
anatofuz
parents:
diff changeset
338 );}
anatofuz
parents:
diff changeset
339
anatofuz
parents:
diff changeset
340 __scoped_allocator_storage(const outer_allocator_type& __o,
anatofuz
parents:
diff changeset
341 const inner_allocator_type& __i) _NOEXCEPT;
anatofuz
parents:
diff changeset
342
anatofuz
parents:
diff changeset
343 template <class...> friend class __scoped_allocator_storage;
anatofuz
parents:
diff changeset
344 };
anatofuz
parents:
diff changeset
345
anatofuz
parents:
diff changeset
346 // __outermost
anatofuz
parents:
diff changeset
347
anatofuz
parents:
diff changeset
348 template <class _Alloc>
anatofuz
parents:
diff changeset
349 decltype(declval<_Alloc>().outer_allocator(), true_type())
anatofuz
parents:
diff changeset
350 __has_outer_allocator_test(_Alloc&& __a);
anatofuz
parents:
diff changeset
351
anatofuz
parents:
diff changeset
352 template <class _Alloc>
anatofuz
parents:
diff changeset
353 false_type
anatofuz
parents:
diff changeset
354 __has_outer_allocator_test(const volatile _Alloc& __a);
anatofuz
parents:
diff changeset
355
anatofuz
parents:
diff changeset
356 template <class _Alloc>
anatofuz
parents:
diff changeset
357 struct __has_outer_allocator
anatofuz
parents:
diff changeset
358 : public common_type
anatofuz
parents:
diff changeset
359 <
anatofuz
parents:
diff changeset
360 decltype(__has_outer_allocator_test(declval<_Alloc&>()))
anatofuz
parents:
diff changeset
361 >::type
anatofuz
parents:
diff changeset
362 {
anatofuz
parents:
diff changeset
363 };
anatofuz
parents:
diff changeset
364
anatofuz
parents:
diff changeset
365 template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value>
anatofuz
parents:
diff changeset
366 struct __outermost
anatofuz
parents:
diff changeset
367 {
anatofuz
parents:
diff changeset
368 typedef _Alloc type;
anatofuz
parents:
diff changeset
369 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
370 type& operator()(type& __a) const _NOEXCEPT {return __a;}
anatofuz
parents:
diff changeset
371 };
anatofuz
parents:
diff changeset
372
anatofuz
parents:
diff changeset
373 template <class _Alloc>
anatofuz
parents:
diff changeset
374 struct __outermost<_Alloc, true>
anatofuz
parents:
diff changeset
375 {
anatofuz
parents:
diff changeset
376 typedef typename remove_reference
anatofuz
parents:
diff changeset
377 <
anatofuz
parents:
diff changeset
378 decltype(_VSTD::declval<_Alloc>().outer_allocator())
anatofuz
parents:
diff changeset
379 >::type _OuterAlloc;
anatofuz
parents:
diff changeset
380 typedef typename __outermost<_OuterAlloc>::type type;
anatofuz
parents:
diff changeset
381 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
382 type& operator()(_Alloc& __a) const _NOEXCEPT
anatofuz
parents:
diff changeset
383 {return __outermost<_OuterAlloc>()(__a.outer_allocator());}
anatofuz
parents:
diff changeset
384 };
anatofuz
parents:
diff changeset
385
anatofuz
parents:
diff changeset
386 template <class _OuterAlloc, class... _InnerAllocs>
anatofuz
parents:
diff changeset
387 class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
anatofuz
parents:
diff changeset
388 : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
anatofuz
parents:
diff changeset
389 {
anatofuz
parents:
diff changeset
390 typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base;
anatofuz
parents:
diff changeset
391 typedef allocator_traits<_OuterAlloc> _OuterTraits;
anatofuz
parents:
diff changeset
392 public:
anatofuz
parents:
diff changeset
393 typedef _OuterAlloc outer_allocator_type;
anatofuz
parents:
diff changeset
394 typedef typename base::inner_allocator_type inner_allocator_type;
anatofuz
parents:
diff changeset
395 typedef typename _OuterTraits::size_type size_type;
anatofuz
parents:
diff changeset
396 typedef typename _OuterTraits::difference_type difference_type;
anatofuz
parents:
diff changeset
397 typedef typename _OuterTraits::pointer pointer;
anatofuz
parents:
diff changeset
398 typedef typename _OuterTraits::const_pointer const_pointer;
anatofuz
parents:
diff changeset
399 typedef typename _OuterTraits::void_pointer void_pointer;
anatofuz
parents:
diff changeset
400 typedef typename _OuterTraits::const_void_pointer const_void_pointer;
anatofuz
parents:
diff changeset
401
anatofuz
parents:
diff changeset
402 typedef integral_constant
anatofuz
parents:
diff changeset
403 <
anatofuz
parents:
diff changeset
404 bool,
anatofuz
parents:
diff changeset
405 __get_poc_copy_assignment<outer_allocator_type,
anatofuz
parents:
diff changeset
406 _InnerAllocs...>::value
anatofuz
parents:
diff changeset
407 > propagate_on_container_copy_assignment;
anatofuz
parents:
diff changeset
408 typedef integral_constant
anatofuz
parents:
diff changeset
409 <
anatofuz
parents:
diff changeset
410 bool,
anatofuz
parents:
diff changeset
411 __get_poc_move_assignment<outer_allocator_type,
anatofuz
parents:
diff changeset
412 _InnerAllocs...>::value
anatofuz
parents:
diff changeset
413 > propagate_on_container_move_assignment;
anatofuz
parents:
diff changeset
414 typedef integral_constant
anatofuz
parents:
diff changeset
415 <
anatofuz
parents:
diff changeset
416 bool,
anatofuz
parents:
diff changeset
417 __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value
anatofuz
parents:
diff changeset
418 > propagate_on_container_swap;
anatofuz
parents:
diff changeset
419 typedef integral_constant
anatofuz
parents:
diff changeset
420 <
anatofuz
parents:
diff changeset
421 bool,
anatofuz
parents:
diff changeset
422 __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value
anatofuz
parents:
diff changeset
423 > is_always_equal;
anatofuz
parents:
diff changeset
424
anatofuz
parents:
diff changeset
425 template <class _Tp>
anatofuz
parents:
diff changeset
426 struct rebind
anatofuz
parents:
diff changeset
427 {
anatofuz
parents:
diff changeset
428 typedef scoped_allocator_adaptor
anatofuz
parents:
diff changeset
429 <
anatofuz
parents:
diff changeset
430 typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs...
anatofuz
parents:
diff changeset
431 > other;
anatofuz
parents:
diff changeset
432 };
anatofuz
parents:
diff changeset
433
anatofuz
parents:
diff changeset
434 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
435 scoped_allocator_adaptor() _NOEXCEPT {}
anatofuz
parents:
diff changeset
436 template <class _OuterA2,
anatofuz
parents:
diff changeset
437 class = typename enable_if<
anatofuz
parents:
diff changeset
438 is_constructible<outer_allocator_type, _OuterA2>::value
anatofuz
parents:
diff changeset
439 >::type>
anatofuz
parents:
diff changeset
440 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
441 scoped_allocator_adaptor(_OuterA2&& __outerAlloc,
anatofuz
parents:
diff changeset
442 const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
anatofuz
parents:
diff changeset
443 : base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {}
anatofuz
parents:
diff changeset
444 // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
anatofuz
parents:
diff changeset
445 template <class _OuterA2,
anatofuz
parents:
diff changeset
446 class = typename enable_if<
anatofuz
parents:
diff changeset
447 is_constructible<outer_allocator_type, const _OuterA2&>::value
anatofuz
parents:
diff changeset
448 >::type>
anatofuz
parents:
diff changeset
449 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
450 scoped_allocator_adaptor(
anatofuz
parents:
diff changeset
451 const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
anatofuz
parents:
diff changeset
452 : base(__other) {}
anatofuz
parents:
diff changeset
453 template <class _OuterA2,
anatofuz
parents:
diff changeset
454 class = typename enable_if<
anatofuz
parents:
diff changeset
455 is_constructible<outer_allocator_type, _OuterA2>::value
anatofuz
parents:
diff changeset
456 >::type>
anatofuz
parents:
diff changeset
457 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
458 scoped_allocator_adaptor(
anatofuz
parents:
diff changeset
459 scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
anatofuz
parents:
diff changeset
460 : base(_VSTD::move(__other)) {}
anatofuz
parents:
diff changeset
461
anatofuz
parents:
diff changeset
462 // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
anatofuz
parents:
diff changeset
463 // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
anatofuz
parents:
diff changeset
464 // ~scoped_allocator_adaptor() = default;
anatofuz
parents:
diff changeset
465
anatofuz
parents:
diff changeset
466 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
467 inner_allocator_type& inner_allocator() _NOEXCEPT
anatofuz
parents:
diff changeset
468 {return base::inner_allocator();}
anatofuz
parents:
diff changeset
469 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
470 const inner_allocator_type& inner_allocator() const _NOEXCEPT
anatofuz
parents:
diff changeset
471 {return base::inner_allocator();}
anatofuz
parents:
diff changeset
472
anatofuz
parents:
diff changeset
473 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
474 outer_allocator_type& outer_allocator() _NOEXCEPT
anatofuz
parents:
diff changeset
475 {return base::outer_allocator();}
anatofuz
parents:
diff changeset
476 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
477 const outer_allocator_type& outer_allocator() const _NOEXCEPT
anatofuz
parents:
diff changeset
478 {return base::outer_allocator();}
anatofuz
parents:
diff changeset
479
anatofuz
parents:
diff changeset
480 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
481 pointer allocate(size_type __n)
anatofuz
parents:
diff changeset
482 {return allocator_traits<outer_allocator_type>::
anatofuz
parents:
diff changeset
483 allocate(outer_allocator(), __n);}
anatofuz
parents:
diff changeset
484 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
485 pointer allocate(size_type __n, const_void_pointer __hint)
anatofuz
parents:
diff changeset
486 {return allocator_traits<outer_allocator_type>::
anatofuz
parents:
diff changeset
487 allocate(outer_allocator(), __n, __hint);}
anatofuz
parents:
diff changeset
488
anatofuz
parents:
diff changeset
489 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
490 void deallocate(pointer __p, size_type __n) _NOEXCEPT
anatofuz
parents:
diff changeset
491 {allocator_traits<outer_allocator_type>::
anatofuz
parents:
diff changeset
492 deallocate(outer_allocator(), __p, __n);}
anatofuz
parents:
diff changeset
493
anatofuz
parents:
diff changeset
494 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
495 size_type max_size() const
anatofuz
parents:
diff changeset
496 {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}
anatofuz
parents:
diff changeset
497
anatofuz
parents:
diff changeset
498 template <class _Tp, class... _Args>
anatofuz
parents:
diff changeset
499 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
500 void construct(_Tp* __p, _Args&& ...__args)
anatofuz
parents:
diff changeset
501 {__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(),
anatofuz
parents:
diff changeset
502 __p, _VSTD::forward<_Args>(__args)...);}
anatofuz
parents:
diff changeset
503
anatofuz
parents:
diff changeset
504 template <class _T1, class _T2, class... _Args1, class... _Args2>
anatofuz
parents:
diff changeset
505 void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
anatofuz
parents:
diff changeset
506 tuple<_Args1...> __x, tuple<_Args2...> __y)
anatofuz
parents:
diff changeset
507 {
anatofuz
parents:
diff changeset
508 typedef __outermost<outer_allocator_type> _OM;
anatofuz
parents:
diff changeset
509 allocator_traits<typename _OM::type>::construct(
anatofuz
parents:
diff changeset
510 _OM()(outer_allocator()), __p, piecewise_construct
anatofuz
parents:
diff changeset
511 , __transform_tuple(
anatofuz
parents:
diff changeset
512 typename __uses_alloc_ctor<
anatofuz
parents:
diff changeset
513 _T1, inner_allocator_type&, _Args1...
anatofuz
parents:
diff changeset
514 >::type()
anatofuz
parents:
diff changeset
515 , _VSTD::move(__x)
anatofuz
parents:
diff changeset
516 , typename __make_tuple_indices<sizeof...(_Args1)>::type{}
anatofuz
parents:
diff changeset
517 )
anatofuz
parents:
diff changeset
518 , __transform_tuple(
anatofuz
parents:
diff changeset
519 typename __uses_alloc_ctor<
anatofuz
parents:
diff changeset
520 _T2, inner_allocator_type&, _Args2...
anatofuz
parents:
diff changeset
521 >::type()
anatofuz
parents:
diff changeset
522 , _VSTD::move(__y)
anatofuz
parents:
diff changeset
523 , typename __make_tuple_indices<sizeof...(_Args2)>::type{}
anatofuz
parents:
diff changeset
524 )
anatofuz
parents:
diff changeset
525 );
anatofuz
parents:
diff changeset
526 }
anatofuz
parents:
diff changeset
527
anatofuz
parents:
diff changeset
528 template <class _T1, class _T2>
anatofuz
parents:
diff changeset
529 void construct(pair<_T1, _T2>* __p)
anatofuz
parents:
diff changeset
530 { construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); }
anatofuz
parents:
diff changeset
531
anatofuz
parents:
diff changeset
532 template <class _T1, class _T2, class _Up, class _Vp>
anatofuz
parents:
diff changeset
533 void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {
anatofuz
parents:
diff changeset
534 construct(__p, piecewise_construct,
anatofuz
parents:
diff changeset
535 _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x)),
anatofuz
parents:
diff changeset
536 _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__y)));
anatofuz
parents:
diff changeset
537 }
anatofuz
parents:
diff changeset
538
anatofuz
parents:
diff changeset
539 template <class _T1, class _T2, class _Up, class _Vp>
anatofuz
parents:
diff changeset
540 void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {
anatofuz
parents:
diff changeset
541 construct(__p, piecewise_construct,
anatofuz
parents:
diff changeset
542 _VSTD::forward_as_tuple(__x.first),
anatofuz
parents:
diff changeset
543 _VSTD::forward_as_tuple(__x.second));
anatofuz
parents:
diff changeset
544 }
anatofuz
parents:
diff changeset
545
anatofuz
parents:
diff changeset
546 template <class _T1, class _T2, class _Up, class _Vp>
anatofuz
parents:
diff changeset
547 void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {
anatofuz
parents:
diff changeset
548 construct(__p, piecewise_construct,
anatofuz
parents:
diff changeset
549 _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
anatofuz
parents:
diff changeset
550 _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
anatofuz
parents:
diff changeset
551 }
anatofuz
parents:
diff changeset
552
anatofuz
parents:
diff changeset
553 template <class _Tp>
anatofuz
parents:
diff changeset
554 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
555 void destroy(_Tp* __p)
anatofuz
parents:
diff changeset
556 {
anatofuz
parents:
diff changeset
557 typedef __outermost<outer_allocator_type> _OM;
anatofuz
parents:
diff changeset
558 allocator_traits<typename _OM::type>::
anatofuz
parents:
diff changeset
559 destroy(_OM()(outer_allocator()), __p);
anatofuz
parents:
diff changeset
560 }
anatofuz
parents:
diff changeset
561
anatofuz
parents:
diff changeset
562 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
563 scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT
anatofuz
parents:
diff changeset
564 {return base::select_on_container_copy_construction();}
anatofuz
parents:
diff changeset
565
anatofuz
parents:
diff changeset
566 private:
anatofuz
parents:
diff changeset
567
anatofuz
parents:
diff changeset
568
anatofuz
parents:
diff changeset
569 template <class _OuterA2,
anatofuz
parents:
diff changeset
570 class = typename enable_if<
anatofuz
parents:
diff changeset
571 is_constructible<outer_allocator_type, _OuterA2>::value
anatofuz
parents:
diff changeset
572 >::type>
anatofuz
parents:
diff changeset
573 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
574 scoped_allocator_adaptor(_OuterA2&& __o,
anatofuz
parents:
diff changeset
575 const inner_allocator_type& __i) _NOEXCEPT
anatofuz
parents:
diff changeset
576 : base(_VSTD::forward<_OuterA2>(__o), __i) {}
anatofuz
parents:
diff changeset
577
anatofuz
parents:
diff changeset
578 template <class _Tp, class... _Args>
anatofuz
parents:
diff changeset
579 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
580 void __construct(integral_constant<int, 0>, _Tp* __p, _Args&& ...__args)
anatofuz
parents:
diff changeset
581 {
anatofuz
parents:
diff changeset
582 typedef __outermost<outer_allocator_type> _OM;
anatofuz
parents:
diff changeset
583 allocator_traits<typename _OM::type>::construct
anatofuz
parents:
diff changeset
584 (
anatofuz
parents:
diff changeset
585 _OM()(outer_allocator()),
anatofuz
parents:
diff changeset
586 __p,
anatofuz
parents:
diff changeset
587 _VSTD::forward<_Args>(__args)...
anatofuz
parents:
diff changeset
588 );
anatofuz
parents:
diff changeset
589 }
anatofuz
parents:
diff changeset
590
anatofuz
parents:
diff changeset
591 template <class _Tp, class... _Args>
anatofuz
parents:
diff changeset
592 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
593 void __construct(integral_constant<int, 1>, _Tp* __p, _Args&& ...__args)
anatofuz
parents:
diff changeset
594 {
anatofuz
parents:
diff changeset
595 typedef __outermost<outer_allocator_type> _OM;
anatofuz
parents:
diff changeset
596 allocator_traits<typename _OM::type>::construct
anatofuz
parents:
diff changeset
597 (
anatofuz
parents:
diff changeset
598 _OM()(outer_allocator()),
anatofuz
parents:
diff changeset
599 __p, allocator_arg, inner_allocator(),
anatofuz
parents:
diff changeset
600 _VSTD::forward<_Args>(__args)...
anatofuz
parents:
diff changeset
601 );
anatofuz
parents:
diff changeset
602 }
anatofuz
parents:
diff changeset
603
anatofuz
parents:
diff changeset
604 template <class _Tp, class... _Args>
anatofuz
parents:
diff changeset
605 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
606 void __construct(integral_constant<int, 2>, _Tp* __p, _Args&& ...__args)
anatofuz
parents:
diff changeset
607 {
anatofuz
parents:
diff changeset
608 typedef __outermost<outer_allocator_type> _OM;
anatofuz
parents:
diff changeset
609 allocator_traits<typename _OM::type>::construct
anatofuz
parents:
diff changeset
610 (
anatofuz
parents:
diff changeset
611 _OM()(outer_allocator()),
anatofuz
parents:
diff changeset
612 __p,
anatofuz
parents:
diff changeset
613 _VSTD::forward<_Args>(__args)...,
anatofuz
parents:
diff changeset
614 inner_allocator()
anatofuz
parents:
diff changeset
615 );
anatofuz
parents:
diff changeset
616 }
anatofuz
parents:
diff changeset
617
anatofuz
parents:
diff changeset
618 template <class ..._Args, size_t ..._Idx>
anatofuz
parents:
diff changeset
619 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
620 tuple<_Args&&...>
anatofuz
parents:
diff changeset
621 __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t,
anatofuz
parents:
diff changeset
622 __tuple_indices<_Idx...>)
anatofuz
parents:
diff changeset
623 {
anatofuz
parents:
diff changeset
624 return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...);
anatofuz
parents:
diff changeset
625 }
anatofuz
parents:
diff changeset
626
anatofuz
parents:
diff changeset
627 template <class ..._Args, size_t ..._Idx>
anatofuz
parents:
diff changeset
628 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
629 tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
anatofuz
parents:
diff changeset
630 __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
anatofuz
parents:
diff changeset
631 __tuple_indices<_Idx...>)
anatofuz
parents:
diff changeset
632 {
anatofuz
parents:
diff changeset
633 using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>;
anatofuz
parents:
diff changeset
634 return _Tup(allocator_arg, inner_allocator(),
anatofuz
parents:
diff changeset
635 _VSTD::get<_Idx>(_VSTD::move(__t))...);
anatofuz
parents:
diff changeset
636 }
anatofuz
parents:
diff changeset
637
anatofuz
parents:
diff changeset
638 template <class ..._Args, size_t ..._Idx>
anatofuz
parents:
diff changeset
639 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
640 tuple<_Args&&..., inner_allocator_type&>
anatofuz
parents:
diff changeset
641 __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
anatofuz
parents:
diff changeset
642 __tuple_indices<_Idx...>)
anatofuz
parents:
diff changeset
643 {
anatofuz
parents:
diff changeset
644 using _Tup = tuple<_Args&&..., inner_allocator_type&>;
anatofuz
parents:
diff changeset
645 return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., inner_allocator());
anatofuz
parents:
diff changeset
646 }
anatofuz
parents:
diff changeset
647
anatofuz
parents:
diff changeset
648 template <class...> friend class __scoped_allocator_storage;
anatofuz
parents:
diff changeset
649 };
anatofuz
parents:
diff changeset
650
anatofuz
parents:
diff changeset
651 template <class _OuterA1, class _OuterA2>
anatofuz
parents:
diff changeset
652 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
653 bool
anatofuz
parents:
diff changeset
654 operator==(const scoped_allocator_adaptor<_OuterA1>& __a,
anatofuz
parents:
diff changeset
655 const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT
anatofuz
parents:
diff changeset
656 {
anatofuz
parents:
diff changeset
657 return __a.outer_allocator() == __b.outer_allocator();
anatofuz
parents:
diff changeset
658 }
anatofuz
parents:
diff changeset
659
anatofuz
parents:
diff changeset
660 template <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs>
anatofuz
parents:
diff changeset
661 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
662 bool
anatofuz
parents:
diff changeset
663 operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a,
anatofuz
parents:
diff changeset
664 const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT
anatofuz
parents:
diff changeset
665 {
anatofuz
parents:
diff changeset
666 return __a.outer_allocator() == __b.outer_allocator() &&
anatofuz
parents:
diff changeset
667 __a.inner_allocator() == __b.inner_allocator();
anatofuz
parents:
diff changeset
668 }
anatofuz
parents:
diff changeset
669
anatofuz
parents:
diff changeset
670 template <class _OuterA1, class _OuterA2, class... _InnerAllocs>
anatofuz
parents:
diff changeset
671 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
672 bool
anatofuz
parents:
diff changeset
673 operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
anatofuz
parents:
diff changeset
674 const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT
anatofuz
parents:
diff changeset
675 {
anatofuz
parents:
diff changeset
676 return !(__a == __b);
anatofuz
parents:
diff changeset
677 }
anatofuz
parents:
diff changeset
678
anatofuz
parents:
diff changeset
679 #endif // !defined(_LIBCPP_CXX03_LANG)
anatofuz
parents:
diff changeset
680
anatofuz
parents:
diff changeset
681 _LIBCPP_END_NAMESPACE_STD
anatofuz
parents:
diff changeset
682
anatofuz
parents:
diff changeset
683 #endif // _LIBCPP_SCOPED_ALLOCATOR