annotate libcxx/include/__split_buffer @ 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 #ifndef _LIBCPP_SPLIT_BUFFER
anatofuz
parents:
diff changeset
3 #define _LIBCPP_SPLIT_BUFFER
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 #include <__config>
anatofuz
parents:
diff changeset
6 #include <type_traits>
anatofuz
parents:
diff changeset
7 #include <algorithm>
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
anatofuz
parents:
diff changeset
10 #pragma GCC system_header
anatofuz
parents:
diff changeset
11 #endif
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 _LIBCPP_PUSH_MACROS
anatofuz
parents:
diff changeset
14 #include <__undef_macros>
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 _LIBCPP_BEGIN_NAMESPACE_STD
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 template <bool>
anatofuz
parents:
diff changeset
20 class __split_buffer_common
anatofuz
parents:
diff changeset
21 {
anatofuz
parents:
diff changeset
22 protected:
anatofuz
parents:
diff changeset
23 void __throw_length_error() const;
anatofuz
parents:
diff changeset
24 void __throw_out_of_range() const;
anatofuz
parents:
diff changeset
25 };
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 template <class _Tp, class _Allocator = allocator<_Tp> >
anatofuz
parents:
diff changeset
28 struct __split_buffer
anatofuz
parents:
diff changeset
29 : private __split_buffer_common<true>
anatofuz
parents:
diff changeset
30 {
anatofuz
parents:
diff changeset
31 private:
anatofuz
parents:
diff changeset
32 __split_buffer(const __split_buffer&);
anatofuz
parents:
diff changeset
33 __split_buffer& operator=(const __split_buffer&);
anatofuz
parents:
diff changeset
34 public:
anatofuz
parents:
diff changeset
35 typedef _Tp value_type;
anatofuz
parents:
diff changeset
36 typedef _Allocator allocator_type;
anatofuz
parents:
diff changeset
37 typedef typename remove_reference<allocator_type>::type __alloc_rr;
anatofuz
parents:
diff changeset
38 typedef allocator_traits<__alloc_rr> __alloc_traits;
anatofuz
parents:
diff changeset
39 typedef value_type& reference;
anatofuz
parents:
diff changeset
40 typedef const value_type& const_reference;
anatofuz
parents:
diff changeset
41 typedef typename __alloc_traits::size_type size_type;
anatofuz
parents:
diff changeset
42 typedef typename __alloc_traits::difference_type difference_type;
anatofuz
parents:
diff changeset
43 typedef typename __alloc_traits::pointer pointer;
anatofuz
parents:
diff changeset
44 typedef typename __alloc_traits::const_pointer const_pointer;
anatofuz
parents:
diff changeset
45 typedef pointer iterator;
anatofuz
parents:
diff changeset
46 typedef const_pointer const_iterator;
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 pointer __first_;
anatofuz
parents:
diff changeset
49 pointer __begin_;
anatofuz
parents:
diff changeset
50 pointer __end_;
anatofuz
parents:
diff changeset
51 __compressed_pair<pointer, allocator_type> __end_cap_;
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
anatofuz
parents:
diff changeset
54 typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
anatofuz
parents:
diff changeset
57 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
anatofuz
parents:
diff changeset
58 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
anatofuz
parents:
diff changeset
59 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
62 __split_buffer()
anatofuz
parents:
diff changeset
63 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
anatofuz
parents:
diff changeset
64 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
65 explicit __split_buffer(__alloc_rr& __a);
anatofuz
parents:
diff changeset
66 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
67 explicit __split_buffer(const __alloc_rr& __a);
anatofuz
parents:
diff changeset
68 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
anatofuz
parents:
diff changeset
69 ~__split_buffer();
anatofuz
parents:
diff changeset
70
anatofuz
parents:
diff changeset
71 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
72 __split_buffer(__split_buffer&& __c)
anatofuz
parents:
diff changeset
73 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
anatofuz
parents:
diff changeset
74 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
anatofuz
parents:
diff changeset
75 __split_buffer& operator=(__split_buffer&& __c)
anatofuz
parents:
diff changeset
76 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
anatofuz
parents:
diff changeset
77 is_nothrow_move_assignable<allocator_type>::value) ||
anatofuz
parents:
diff changeset
78 !__alloc_traits::propagate_on_container_move_assignment::value);
anatofuz
parents:
diff changeset
79 #endif // _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
anatofuz
parents:
diff changeset
82 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
anatofuz
parents:
diff changeset
83 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
anatofuz
parents:
diff changeset
84 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
87 void clear() _NOEXCEPT
anatofuz
parents:
diff changeset
88 {__destruct_at_end(__begin_);}
anatofuz
parents:
diff changeset
89 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
anatofuz
parents:
diff changeset
90 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
anatofuz
parents:
diff changeset
91 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
anatofuz
parents:
diff changeset
92 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
anatofuz
parents:
diff changeset
93 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
anatofuz
parents:
diff changeset
94
anatofuz
parents:
diff changeset
95 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
anatofuz
parents:
diff changeset
96 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
anatofuz
parents:
diff changeset
97 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
anatofuz
parents:
diff changeset
98 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
anatofuz
parents:
diff changeset
99
anatofuz
parents:
diff changeset
100 void reserve(size_type __n);
anatofuz
parents:
diff changeset
101 void shrink_to_fit() _NOEXCEPT;
anatofuz
parents:
diff changeset
102 void push_front(const_reference __x);
anatofuz
parents:
diff changeset
103 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
anatofuz
parents:
diff changeset
104 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
105 void push_front(value_type&& __x);
anatofuz
parents:
diff changeset
106 void push_back(value_type&& __x);
anatofuz
parents:
diff changeset
107 template <class... _Args>
anatofuz
parents:
diff changeset
108 void emplace_back(_Args&&... __args);
anatofuz
parents:
diff changeset
109 #endif // !defined(_LIBCPP_CXX03_LANG)
anatofuz
parents:
diff changeset
110
anatofuz
parents:
diff changeset
111 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
anatofuz
parents:
diff changeset
112 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
anatofuz
parents:
diff changeset
113
anatofuz
parents:
diff changeset
114 void __construct_at_end(size_type __n);
anatofuz
parents:
diff changeset
115 void __construct_at_end(size_type __n, const_reference __x);
anatofuz
parents:
diff changeset
116 template <class _InputIter>
anatofuz
parents:
diff changeset
117 typename enable_if
anatofuz
parents:
diff changeset
118 <
anatofuz
parents:
diff changeset
119 __is_cpp17_input_iterator<_InputIter>::value &&
anatofuz
parents:
diff changeset
120 !__is_cpp17_forward_iterator<_InputIter>::value,
anatofuz
parents:
diff changeset
121 void
anatofuz
parents:
diff changeset
122 >::type
anatofuz
parents:
diff changeset
123 __construct_at_end(_InputIter __first, _InputIter __last);
anatofuz
parents:
diff changeset
124 template <class _ForwardIterator>
anatofuz
parents:
diff changeset
125 typename enable_if
anatofuz
parents:
diff changeset
126 <
anatofuz
parents:
diff changeset
127 __is_cpp17_forward_iterator<_ForwardIterator>::value,
anatofuz
parents:
diff changeset
128 void
anatofuz
parents:
diff changeset
129 >::type
anatofuz
parents:
diff changeset
130 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
anatofuz
parents:
diff changeset
131
anatofuz
parents:
diff changeset
132 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
anatofuz
parents:
diff changeset
133 {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
anatofuz
parents:
diff changeset
134 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
135 void __destruct_at_begin(pointer __new_begin, false_type);
anatofuz
parents:
diff changeset
136 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
137 void __destruct_at_begin(pointer __new_begin, true_type);
anatofuz
parents:
diff changeset
138
anatofuz
parents:
diff changeset
139 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
140 void __destruct_at_end(pointer __new_last) _NOEXCEPT
anatofuz
parents:
diff changeset
141 {__destruct_at_end(__new_last, false_type());}
anatofuz
parents:
diff changeset
142 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
143 void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
anatofuz
parents:
diff changeset
144 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
145 void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
anatofuz
parents:
diff changeset
146
anatofuz
parents:
diff changeset
147 void swap(__split_buffer& __x)
anatofuz
parents:
diff changeset
148 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
anatofuz
parents:
diff changeset
149 __is_nothrow_swappable<__alloc_rr>::value);
anatofuz
parents:
diff changeset
150
anatofuz
parents:
diff changeset
151 bool __invariants() const;
anatofuz
parents:
diff changeset
152
anatofuz
parents:
diff changeset
153 private:
anatofuz
parents:
diff changeset
154 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
155 void __move_assign_alloc(__split_buffer& __c, true_type)
anatofuz
parents:
diff changeset
156 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
anatofuz
parents:
diff changeset
157 {
anatofuz
parents:
diff changeset
158 __alloc() = _VSTD::move(__c.__alloc());
anatofuz
parents:
diff changeset
159 }
anatofuz
parents:
diff changeset
160
anatofuz
parents:
diff changeset
161 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
162 void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
anatofuz
parents:
diff changeset
163 {}
anatofuz
parents:
diff changeset
164
anatofuz
parents:
diff changeset
165 struct _ConstructTransaction {
anatofuz
parents:
diff changeset
166 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
anatofuz
parents:
diff changeset
167 : __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
anatofuz
parents:
diff changeset
168 }
anatofuz
parents:
diff changeset
169 ~_ConstructTransaction() {
anatofuz
parents:
diff changeset
170 *__dest_ = __pos_;
anatofuz
parents:
diff changeset
171 }
anatofuz
parents:
diff changeset
172 pointer __pos_;
anatofuz
parents:
diff changeset
173 const pointer __end_;
anatofuz
parents:
diff changeset
174 private:
anatofuz
parents:
diff changeset
175 pointer *__dest_;
anatofuz
parents:
diff changeset
176 };
anatofuz
parents:
diff changeset
177 };
anatofuz
parents:
diff changeset
178
anatofuz
parents:
diff changeset
179 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
180 bool
anatofuz
parents:
diff changeset
181 __split_buffer<_Tp, _Allocator>::__invariants() const
anatofuz
parents:
diff changeset
182 {
anatofuz
parents:
diff changeset
183 if (__first_ == nullptr)
anatofuz
parents:
diff changeset
184 {
anatofuz
parents:
diff changeset
185 if (__begin_ != nullptr)
anatofuz
parents:
diff changeset
186 return false;
anatofuz
parents:
diff changeset
187 if (__end_ != nullptr)
anatofuz
parents:
diff changeset
188 return false;
anatofuz
parents:
diff changeset
189 if (__end_cap() != nullptr)
anatofuz
parents:
diff changeset
190 return false;
anatofuz
parents:
diff changeset
191 }
anatofuz
parents:
diff changeset
192 else
anatofuz
parents:
diff changeset
193 {
anatofuz
parents:
diff changeset
194 if (__begin_ < __first_)
anatofuz
parents:
diff changeset
195 return false;
anatofuz
parents:
diff changeset
196 if (__end_ < __begin_)
anatofuz
parents:
diff changeset
197 return false;
anatofuz
parents:
diff changeset
198 if (__end_cap() < __end_)
anatofuz
parents:
diff changeset
199 return false;
anatofuz
parents:
diff changeset
200 }
anatofuz
parents:
diff changeset
201 return true;
anatofuz
parents:
diff changeset
202 }
anatofuz
parents:
diff changeset
203
anatofuz
parents:
diff changeset
204 // Default constructs __n objects starting at __end_
anatofuz
parents:
diff changeset
205 // throws if construction throws
anatofuz
parents:
diff changeset
206 // Precondition: __n > 0
anatofuz
parents:
diff changeset
207 // Precondition: size() + __n <= capacity()
anatofuz
parents:
diff changeset
208 // Postcondition: size() == size() + __n
anatofuz
parents:
diff changeset
209 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
210 void
anatofuz
parents:
diff changeset
211 __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
anatofuz
parents:
diff changeset
212 {
anatofuz
parents:
diff changeset
213 _ConstructTransaction __tx(&this->__end_, __n);
anatofuz
parents:
diff changeset
214 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
anatofuz
parents:
diff changeset
215 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_));
anatofuz
parents:
diff changeset
216 }
anatofuz
parents:
diff changeset
217 }
anatofuz
parents:
diff changeset
218
anatofuz
parents:
diff changeset
219 // Copy constructs __n objects starting at __end_ from __x
anatofuz
parents:
diff changeset
220 // throws if construction throws
anatofuz
parents:
diff changeset
221 // Precondition: __n > 0
anatofuz
parents:
diff changeset
222 // Precondition: size() + __n <= capacity()
anatofuz
parents:
diff changeset
223 // Postcondition: size() == old size() + __n
anatofuz
parents:
diff changeset
224 // Postcondition: [i] == __x for all i in [size() - __n, __n)
anatofuz
parents:
diff changeset
225 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
226 void
anatofuz
parents:
diff changeset
227 __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
anatofuz
parents:
diff changeset
228 {
anatofuz
parents:
diff changeset
229 _ConstructTransaction __tx(&this->__end_, __n);
anatofuz
parents:
diff changeset
230 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
anatofuz
parents:
diff changeset
231 __alloc_traits::construct(this->__alloc(),
anatofuz
parents:
diff changeset
232 _VSTD::__to_address(__tx.__pos_), __x);
anatofuz
parents:
diff changeset
233 }
anatofuz
parents:
diff changeset
234 }
anatofuz
parents:
diff changeset
235
anatofuz
parents:
diff changeset
236 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
237 template <class _InputIter>
anatofuz
parents:
diff changeset
238 typename enable_if
anatofuz
parents:
diff changeset
239 <
anatofuz
parents:
diff changeset
240 __is_cpp17_input_iterator<_InputIter>::value &&
anatofuz
parents:
diff changeset
241 !__is_cpp17_forward_iterator<_InputIter>::value,
anatofuz
parents:
diff changeset
242 void
anatofuz
parents:
diff changeset
243 >::type
anatofuz
parents:
diff changeset
244 __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
anatofuz
parents:
diff changeset
245 {
anatofuz
parents:
diff changeset
246 __alloc_rr& __a = this->__alloc();
anatofuz
parents:
diff changeset
247 for (; __first != __last; ++__first)
anatofuz
parents:
diff changeset
248 {
anatofuz
parents:
diff changeset
249 if (__end_ == __end_cap())
anatofuz
parents:
diff changeset
250 {
anatofuz
parents:
diff changeset
251 size_type __old_cap = __end_cap() - __first_;
anatofuz
parents:
diff changeset
252 size_type __new_cap = _VSTD::max<size_type>(2 * __old_cap, 8);
anatofuz
parents:
diff changeset
253 __split_buffer __buf(__new_cap, 0, __a);
anatofuz
parents:
diff changeset
254 for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_)
anatofuz
parents:
diff changeset
255 __alloc_traits::construct(__buf.__alloc(),
anatofuz
parents:
diff changeset
256 _VSTD::__to_address(__buf.__end_), _VSTD::move(*__p));
anatofuz
parents:
diff changeset
257 swap(__buf);
anatofuz
parents:
diff changeset
258 }
anatofuz
parents:
diff changeset
259 __alloc_traits::construct(__a, _VSTD::__to_address(this->__end_), *__first);
anatofuz
parents:
diff changeset
260 ++this->__end_;
anatofuz
parents:
diff changeset
261 }
anatofuz
parents:
diff changeset
262 }
anatofuz
parents:
diff changeset
263
anatofuz
parents:
diff changeset
264 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
265 template <class _ForwardIterator>
anatofuz
parents:
diff changeset
266 typename enable_if
anatofuz
parents:
diff changeset
267 <
anatofuz
parents:
diff changeset
268 __is_cpp17_forward_iterator<_ForwardIterator>::value,
anatofuz
parents:
diff changeset
269 void
anatofuz
parents:
diff changeset
270 >::type
anatofuz
parents:
diff changeset
271 __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
anatofuz
parents:
diff changeset
272 {
anatofuz
parents:
diff changeset
273 _ConstructTransaction __tx(&this->__end_, std::distance(__first, __last));
anatofuz
parents:
diff changeset
274 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, ++__first) {
anatofuz
parents:
diff changeset
275 __alloc_traits::construct(this->__alloc(),
anatofuz
parents:
diff changeset
276 _VSTD::__to_address(__tx.__pos_), *__first);
anatofuz
parents:
diff changeset
277 }
anatofuz
parents:
diff changeset
278 }
anatofuz
parents:
diff changeset
279
anatofuz
parents:
diff changeset
280 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
281 inline
anatofuz
parents:
diff changeset
282 void
anatofuz
parents:
diff changeset
283 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
anatofuz
parents:
diff changeset
284 {
anatofuz
parents:
diff changeset
285 while (__begin_ != __new_begin)
anatofuz
parents:
diff changeset
286 __alloc_traits::destroy(__alloc(), __to_address(__begin_++));
anatofuz
parents:
diff changeset
287 }
anatofuz
parents:
diff changeset
288
anatofuz
parents:
diff changeset
289 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
290 inline
anatofuz
parents:
diff changeset
291 void
anatofuz
parents:
diff changeset
292 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
anatofuz
parents:
diff changeset
293 {
anatofuz
parents:
diff changeset
294 __begin_ = __new_begin;
anatofuz
parents:
diff changeset
295 }
anatofuz
parents:
diff changeset
296
anatofuz
parents:
diff changeset
297 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
298 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
299 void
anatofuz
parents:
diff changeset
300 __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
anatofuz
parents:
diff changeset
301 {
anatofuz
parents:
diff changeset
302 while (__new_last != __end_)
anatofuz
parents:
diff changeset
303 __alloc_traits::destroy(__alloc(), __to_address(--__end_));
anatofuz
parents:
diff changeset
304 }
anatofuz
parents:
diff changeset
305
anatofuz
parents:
diff changeset
306 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
307 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
308 void
anatofuz
parents:
diff changeset
309 __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
anatofuz
parents:
diff changeset
310 {
anatofuz
parents:
diff changeset
311 __end_ = __new_last;
anatofuz
parents:
diff changeset
312 }
anatofuz
parents:
diff changeset
313
anatofuz
parents:
diff changeset
314 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
315 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
anatofuz
parents:
diff changeset
316 : __end_cap_(nullptr, __a)
anatofuz
parents:
diff changeset
317 {
anatofuz
parents:
diff changeset
318 __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
anatofuz
parents:
diff changeset
319 __begin_ = __end_ = __first_ + __start;
anatofuz
parents:
diff changeset
320 __end_cap() = __first_ + __cap;
anatofuz
parents:
diff changeset
321 }
anatofuz
parents:
diff changeset
322
anatofuz
parents:
diff changeset
323 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
324 inline
anatofuz
parents:
diff changeset
325 __split_buffer<_Tp, _Allocator>::__split_buffer()
anatofuz
parents:
diff changeset
326 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
anatofuz
parents:
diff changeset
327 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag())
anatofuz
parents:
diff changeset
328 {
anatofuz
parents:
diff changeset
329 }
anatofuz
parents:
diff changeset
330
anatofuz
parents:
diff changeset
331 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
332 inline
anatofuz
parents:
diff changeset
333 __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
anatofuz
parents:
diff changeset
334 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
anatofuz
parents:
diff changeset
335 {
anatofuz
parents:
diff changeset
336 }
anatofuz
parents:
diff changeset
337
anatofuz
parents:
diff changeset
338 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
339 inline
anatofuz
parents:
diff changeset
340 __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
anatofuz
parents:
diff changeset
341 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
anatofuz
parents:
diff changeset
342 {
anatofuz
parents:
diff changeset
343 }
anatofuz
parents:
diff changeset
344
anatofuz
parents:
diff changeset
345 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
346 __split_buffer<_Tp, _Allocator>::~__split_buffer()
anatofuz
parents:
diff changeset
347 {
anatofuz
parents:
diff changeset
348 clear();
anatofuz
parents:
diff changeset
349 if (__first_)
anatofuz
parents:
diff changeset
350 __alloc_traits::deallocate(__alloc(), __first_, capacity());
anatofuz
parents:
diff changeset
351 }
anatofuz
parents:
diff changeset
352
anatofuz
parents:
diff changeset
353 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
354
anatofuz
parents:
diff changeset
355 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
356 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
anatofuz
parents:
diff changeset
357 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
anatofuz
parents:
diff changeset
358 : __first_(_VSTD::move(__c.__first_)),
anatofuz
parents:
diff changeset
359 __begin_(_VSTD::move(__c.__begin_)),
anatofuz
parents:
diff changeset
360 __end_(_VSTD::move(__c.__end_)),
anatofuz
parents:
diff changeset
361 __end_cap_(_VSTD::move(__c.__end_cap_))
anatofuz
parents:
diff changeset
362 {
anatofuz
parents:
diff changeset
363 __c.__first_ = nullptr;
anatofuz
parents:
diff changeset
364 __c.__begin_ = nullptr;
anatofuz
parents:
diff changeset
365 __c.__end_ = nullptr;
anatofuz
parents:
diff changeset
366 __c.__end_cap() = nullptr;
anatofuz
parents:
diff changeset
367 }
anatofuz
parents:
diff changeset
368
anatofuz
parents:
diff changeset
369 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
370 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
anatofuz
parents:
diff changeset
371 : __end_cap_(nullptr, __a)
anatofuz
parents:
diff changeset
372 {
anatofuz
parents:
diff changeset
373 if (__a == __c.__alloc())
anatofuz
parents:
diff changeset
374 {
anatofuz
parents:
diff changeset
375 __first_ = __c.__first_;
anatofuz
parents:
diff changeset
376 __begin_ = __c.__begin_;
anatofuz
parents:
diff changeset
377 __end_ = __c.__end_;
anatofuz
parents:
diff changeset
378 __end_cap() = __c.__end_cap();
anatofuz
parents:
diff changeset
379 __c.__first_ = nullptr;
anatofuz
parents:
diff changeset
380 __c.__begin_ = nullptr;
anatofuz
parents:
diff changeset
381 __c.__end_ = nullptr;
anatofuz
parents:
diff changeset
382 __c.__end_cap() = nullptr;
anatofuz
parents:
diff changeset
383 }
anatofuz
parents:
diff changeset
384 else
anatofuz
parents:
diff changeset
385 {
anatofuz
parents:
diff changeset
386 size_type __cap = __c.size();
anatofuz
parents:
diff changeset
387 __first_ = __alloc_traits::allocate(__alloc(), __cap);
anatofuz
parents:
diff changeset
388 __begin_ = __end_ = __first_;
anatofuz
parents:
diff changeset
389 __end_cap() = __first_ + __cap;
anatofuz
parents:
diff changeset
390 typedef move_iterator<iterator> _Ip;
anatofuz
parents:
diff changeset
391 __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
anatofuz
parents:
diff changeset
392 }
anatofuz
parents:
diff changeset
393 }
anatofuz
parents:
diff changeset
394
anatofuz
parents:
diff changeset
395 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
396 __split_buffer<_Tp, _Allocator>&
anatofuz
parents:
diff changeset
397 __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
anatofuz
parents:
diff changeset
398 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
anatofuz
parents:
diff changeset
399 is_nothrow_move_assignable<allocator_type>::value) ||
anatofuz
parents:
diff changeset
400 !__alloc_traits::propagate_on_container_move_assignment::value)
anatofuz
parents:
diff changeset
401 {
anatofuz
parents:
diff changeset
402 clear();
anatofuz
parents:
diff changeset
403 shrink_to_fit();
anatofuz
parents:
diff changeset
404 __first_ = __c.__first_;
anatofuz
parents:
diff changeset
405 __begin_ = __c.__begin_;
anatofuz
parents:
diff changeset
406 __end_ = __c.__end_;
anatofuz
parents:
diff changeset
407 __end_cap() = __c.__end_cap();
anatofuz
parents:
diff changeset
408 __move_assign_alloc(__c,
anatofuz
parents:
diff changeset
409 integral_constant<bool,
anatofuz
parents:
diff changeset
410 __alloc_traits::propagate_on_container_move_assignment::value>());
anatofuz
parents:
diff changeset
411 __c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
anatofuz
parents:
diff changeset
412 return *this;
anatofuz
parents:
diff changeset
413 }
anatofuz
parents:
diff changeset
414
anatofuz
parents:
diff changeset
415 #endif // _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
416
anatofuz
parents:
diff changeset
417 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
418 void
anatofuz
parents:
diff changeset
419 __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
anatofuz
parents:
diff changeset
420 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
anatofuz
parents:
diff changeset
421 __is_nothrow_swappable<__alloc_rr>::value)
anatofuz
parents:
diff changeset
422 {
anatofuz
parents:
diff changeset
423 _VSTD::swap(__first_, __x.__first_);
anatofuz
parents:
diff changeset
424 _VSTD::swap(__begin_, __x.__begin_);
anatofuz
parents:
diff changeset
425 _VSTD::swap(__end_, __x.__end_);
anatofuz
parents:
diff changeset
426 _VSTD::swap(__end_cap(), __x.__end_cap());
anatofuz
parents:
diff changeset
427 __swap_allocator(__alloc(), __x.__alloc());
anatofuz
parents:
diff changeset
428 }
anatofuz
parents:
diff changeset
429
anatofuz
parents:
diff changeset
430 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
431 void
anatofuz
parents:
diff changeset
432 __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
anatofuz
parents:
diff changeset
433 {
anatofuz
parents:
diff changeset
434 if (__n < capacity())
anatofuz
parents:
diff changeset
435 {
anatofuz
parents:
diff changeset
436 __split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc());
anatofuz
parents:
diff changeset
437 __t.__construct_at_end(move_iterator<pointer>(__begin_),
anatofuz
parents:
diff changeset
438 move_iterator<pointer>(__end_));
anatofuz
parents:
diff changeset
439 _VSTD::swap(__first_, __t.__first_);
anatofuz
parents:
diff changeset
440 _VSTD::swap(__begin_, __t.__begin_);
anatofuz
parents:
diff changeset
441 _VSTD::swap(__end_, __t.__end_);
anatofuz
parents:
diff changeset
442 _VSTD::swap(__end_cap(), __t.__end_cap());
anatofuz
parents:
diff changeset
443 }
anatofuz
parents:
diff changeset
444 }
anatofuz
parents:
diff changeset
445
anatofuz
parents:
diff changeset
446 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
447 void
anatofuz
parents:
diff changeset
448 __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
anatofuz
parents:
diff changeset
449 {
anatofuz
parents:
diff changeset
450 if (capacity() > size())
anatofuz
parents:
diff changeset
451 {
anatofuz
parents:
diff changeset
452 #ifndef _LIBCPP_NO_EXCEPTIONS
anatofuz
parents:
diff changeset
453 try
anatofuz
parents:
diff changeset
454 {
anatofuz
parents:
diff changeset
455 #endif // _LIBCPP_NO_EXCEPTIONS
anatofuz
parents:
diff changeset
456 __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc());
anatofuz
parents:
diff changeset
457 __t.__construct_at_end(move_iterator<pointer>(__begin_),
anatofuz
parents:
diff changeset
458 move_iterator<pointer>(__end_));
anatofuz
parents:
diff changeset
459 __t.__end_ = __t.__begin_ + (__end_ - __begin_);
anatofuz
parents:
diff changeset
460 _VSTD::swap(__first_, __t.__first_);
anatofuz
parents:
diff changeset
461 _VSTD::swap(__begin_, __t.__begin_);
anatofuz
parents:
diff changeset
462 _VSTD::swap(__end_, __t.__end_);
anatofuz
parents:
diff changeset
463 _VSTD::swap(__end_cap(), __t.__end_cap());
anatofuz
parents:
diff changeset
464 #ifndef _LIBCPP_NO_EXCEPTIONS
anatofuz
parents:
diff changeset
465 }
anatofuz
parents:
diff changeset
466 catch (...)
anatofuz
parents:
diff changeset
467 {
anatofuz
parents:
diff changeset
468 }
anatofuz
parents:
diff changeset
469 #endif // _LIBCPP_NO_EXCEPTIONS
anatofuz
parents:
diff changeset
470 }
anatofuz
parents:
diff changeset
471 }
anatofuz
parents:
diff changeset
472
anatofuz
parents:
diff changeset
473 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
474 void
anatofuz
parents:
diff changeset
475 __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
anatofuz
parents:
diff changeset
476 {
anatofuz
parents:
diff changeset
477 if (__begin_ == __first_)
anatofuz
parents:
diff changeset
478 {
anatofuz
parents:
diff changeset
479 if (__end_ < __end_cap())
anatofuz
parents:
diff changeset
480 {
anatofuz
parents:
diff changeset
481 difference_type __d = __end_cap() - __end_;
anatofuz
parents:
diff changeset
482 __d = (__d + 1) / 2;
anatofuz
parents:
diff changeset
483 __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d);
anatofuz
parents:
diff changeset
484 __end_ += __d;
anatofuz
parents:
diff changeset
485 }
anatofuz
parents:
diff changeset
486 else
anatofuz
parents:
diff changeset
487 {
anatofuz
parents:
diff changeset
488 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
anatofuz
parents:
diff changeset
489 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
anatofuz
parents:
diff changeset
490 __t.__construct_at_end(move_iterator<pointer>(__begin_),
anatofuz
parents:
diff changeset
491 move_iterator<pointer>(__end_));
anatofuz
parents:
diff changeset
492 _VSTD::swap(__first_, __t.__first_);
anatofuz
parents:
diff changeset
493 _VSTD::swap(__begin_, __t.__begin_);
anatofuz
parents:
diff changeset
494 _VSTD::swap(__end_, __t.__end_);
anatofuz
parents:
diff changeset
495 _VSTD::swap(__end_cap(), __t.__end_cap());
anatofuz
parents:
diff changeset
496 }
anatofuz
parents:
diff changeset
497 }
anatofuz
parents:
diff changeset
498 __alloc_traits::construct(__alloc(), _VSTD::__to_address(__begin_-1), __x);
anatofuz
parents:
diff changeset
499 --__begin_;
anatofuz
parents:
diff changeset
500 }
anatofuz
parents:
diff changeset
501
anatofuz
parents:
diff changeset
502 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
503
anatofuz
parents:
diff changeset
504 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
505 void
anatofuz
parents:
diff changeset
506 __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
anatofuz
parents:
diff changeset
507 {
anatofuz
parents:
diff changeset
508 if (__begin_ == __first_)
anatofuz
parents:
diff changeset
509 {
anatofuz
parents:
diff changeset
510 if (__end_ < __end_cap())
anatofuz
parents:
diff changeset
511 {
anatofuz
parents:
diff changeset
512 difference_type __d = __end_cap() - __end_;
anatofuz
parents:
diff changeset
513 __d = (__d + 1) / 2;
anatofuz
parents:
diff changeset
514 __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d);
anatofuz
parents:
diff changeset
515 __end_ += __d;
anatofuz
parents:
diff changeset
516 }
anatofuz
parents:
diff changeset
517 else
anatofuz
parents:
diff changeset
518 {
anatofuz
parents:
diff changeset
519 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
anatofuz
parents:
diff changeset
520 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
anatofuz
parents:
diff changeset
521 __t.__construct_at_end(move_iterator<pointer>(__begin_),
anatofuz
parents:
diff changeset
522 move_iterator<pointer>(__end_));
anatofuz
parents:
diff changeset
523 _VSTD::swap(__first_, __t.__first_);
anatofuz
parents:
diff changeset
524 _VSTD::swap(__begin_, __t.__begin_);
anatofuz
parents:
diff changeset
525 _VSTD::swap(__end_, __t.__end_);
anatofuz
parents:
diff changeset
526 _VSTD::swap(__end_cap(), __t.__end_cap());
anatofuz
parents:
diff changeset
527 }
anatofuz
parents:
diff changeset
528 }
anatofuz
parents:
diff changeset
529 __alloc_traits::construct(__alloc(), _VSTD::__to_address(__begin_-1),
anatofuz
parents:
diff changeset
530 _VSTD::move(__x));
anatofuz
parents:
diff changeset
531 --__begin_;
anatofuz
parents:
diff changeset
532 }
anatofuz
parents:
diff changeset
533
anatofuz
parents:
diff changeset
534 #endif // _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
535
anatofuz
parents:
diff changeset
536 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
537 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
538 void
anatofuz
parents:
diff changeset
539 __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
anatofuz
parents:
diff changeset
540 {
anatofuz
parents:
diff changeset
541 if (__end_ == __end_cap())
anatofuz
parents:
diff changeset
542 {
anatofuz
parents:
diff changeset
543 if (__begin_ > __first_)
anatofuz
parents:
diff changeset
544 {
anatofuz
parents:
diff changeset
545 difference_type __d = __begin_ - __first_;
anatofuz
parents:
diff changeset
546 __d = (__d + 1) / 2;
anatofuz
parents:
diff changeset
547 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
anatofuz
parents:
diff changeset
548 __begin_ -= __d;
anatofuz
parents:
diff changeset
549 }
anatofuz
parents:
diff changeset
550 else
anatofuz
parents:
diff changeset
551 {
anatofuz
parents:
diff changeset
552 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
anatofuz
parents:
diff changeset
553 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
anatofuz
parents:
diff changeset
554 __t.__construct_at_end(move_iterator<pointer>(__begin_),
anatofuz
parents:
diff changeset
555 move_iterator<pointer>(__end_));
anatofuz
parents:
diff changeset
556 _VSTD::swap(__first_, __t.__first_);
anatofuz
parents:
diff changeset
557 _VSTD::swap(__begin_, __t.__begin_);
anatofuz
parents:
diff changeset
558 _VSTD::swap(__end_, __t.__end_);
anatofuz
parents:
diff changeset
559 _VSTD::swap(__end_cap(), __t.__end_cap());
anatofuz
parents:
diff changeset
560 }
anatofuz
parents:
diff changeset
561 }
anatofuz
parents:
diff changeset
562 __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_), __x);
anatofuz
parents:
diff changeset
563 ++__end_;
anatofuz
parents:
diff changeset
564 }
anatofuz
parents:
diff changeset
565
anatofuz
parents:
diff changeset
566 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
567
anatofuz
parents:
diff changeset
568 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
569 void
anatofuz
parents:
diff changeset
570 __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
anatofuz
parents:
diff changeset
571 {
anatofuz
parents:
diff changeset
572 if (__end_ == __end_cap())
anatofuz
parents:
diff changeset
573 {
anatofuz
parents:
diff changeset
574 if (__begin_ > __first_)
anatofuz
parents:
diff changeset
575 {
anatofuz
parents:
diff changeset
576 difference_type __d = __begin_ - __first_;
anatofuz
parents:
diff changeset
577 __d = (__d + 1) / 2;
anatofuz
parents:
diff changeset
578 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
anatofuz
parents:
diff changeset
579 __begin_ -= __d;
anatofuz
parents:
diff changeset
580 }
anatofuz
parents:
diff changeset
581 else
anatofuz
parents:
diff changeset
582 {
anatofuz
parents:
diff changeset
583 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
anatofuz
parents:
diff changeset
584 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
anatofuz
parents:
diff changeset
585 __t.__construct_at_end(move_iterator<pointer>(__begin_),
anatofuz
parents:
diff changeset
586 move_iterator<pointer>(__end_));
anatofuz
parents:
diff changeset
587 _VSTD::swap(__first_, __t.__first_);
anatofuz
parents:
diff changeset
588 _VSTD::swap(__begin_, __t.__begin_);
anatofuz
parents:
diff changeset
589 _VSTD::swap(__end_, __t.__end_);
anatofuz
parents:
diff changeset
590 _VSTD::swap(__end_cap(), __t.__end_cap());
anatofuz
parents:
diff changeset
591 }
anatofuz
parents:
diff changeset
592 }
anatofuz
parents:
diff changeset
593 __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_),
anatofuz
parents:
diff changeset
594 _VSTD::move(__x));
anatofuz
parents:
diff changeset
595 ++__end_;
anatofuz
parents:
diff changeset
596 }
anatofuz
parents:
diff changeset
597
anatofuz
parents:
diff changeset
598 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
599 template <class... _Args>
anatofuz
parents:
diff changeset
600 void
anatofuz
parents:
diff changeset
601 __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
anatofuz
parents:
diff changeset
602 {
anatofuz
parents:
diff changeset
603 if (__end_ == __end_cap())
anatofuz
parents:
diff changeset
604 {
anatofuz
parents:
diff changeset
605 if (__begin_ > __first_)
anatofuz
parents:
diff changeset
606 {
anatofuz
parents:
diff changeset
607 difference_type __d = __begin_ - __first_;
anatofuz
parents:
diff changeset
608 __d = (__d + 1) / 2;
anatofuz
parents:
diff changeset
609 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
anatofuz
parents:
diff changeset
610 __begin_ -= __d;
anatofuz
parents:
diff changeset
611 }
anatofuz
parents:
diff changeset
612 else
anatofuz
parents:
diff changeset
613 {
anatofuz
parents:
diff changeset
614 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
anatofuz
parents:
diff changeset
615 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
anatofuz
parents:
diff changeset
616 __t.__construct_at_end(move_iterator<pointer>(__begin_),
anatofuz
parents:
diff changeset
617 move_iterator<pointer>(__end_));
anatofuz
parents:
diff changeset
618 _VSTD::swap(__first_, __t.__first_);
anatofuz
parents:
diff changeset
619 _VSTD::swap(__begin_, __t.__begin_);
anatofuz
parents:
diff changeset
620 _VSTD::swap(__end_, __t.__end_);
anatofuz
parents:
diff changeset
621 _VSTD::swap(__end_cap(), __t.__end_cap());
anatofuz
parents:
diff changeset
622 }
anatofuz
parents:
diff changeset
623 }
anatofuz
parents:
diff changeset
624 __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_),
anatofuz
parents:
diff changeset
625 _VSTD::forward<_Args>(__args)...);
anatofuz
parents:
diff changeset
626 ++__end_;
anatofuz
parents:
diff changeset
627 }
anatofuz
parents:
diff changeset
628
anatofuz
parents:
diff changeset
629 #endif // _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
630
anatofuz
parents:
diff changeset
631 template <class _Tp, class _Allocator>
anatofuz
parents:
diff changeset
632 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
633 void
anatofuz
parents:
diff changeset
634 swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
anatofuz
parents:
diff changeset
635 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
anatofuz
parents:
diff changeset
636 {
anatofuz
parents:
diff changeset
637 __x.swap(__y);
anatofuz
parents:
diff changeset
638 }
anatofuz
parents:
diff changeset
639
anatofuz
parents:
diff changeset
640 _LIBCPP_END_NAMESPACE_STD
anatofuz
parents:
diff changeset
641
anatofuz
parents:
diff changeset
642 _LIBCPP_POP_MACROS
anatofuz
parents:
diff changeset
643
anatofuz
parents:
diff changeset
644 #endif // _LIBCPP_SPLIT_BUFFER