Mercurial > hg > CbC > CbC_llvm
comparison libcxx/include/__split_buffer @ 252:1f2b6ac9f198 llvm-original
LLVM16-1
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Aug 2023 09:04:13 +0900 |
parents | c4bab56944e8 |
children |
comparison
equal
deleted
inserted
replaced
237:c80f45b162ad | 252:1f2b6ac9f198 |
---|---|
20 #include <__memory/allocate_at_least.h> | 20 #include <__memory/allocate_at_least.h> |
21 #include <__memory/allocator.h> | 21 #include <__memory/allocator.h> |
22 #include <__memory/allocator_traits.h> | 22 #include <__memory/allocator_traits.h> |
23 #include <__memory/compressed_pair.h> | 23 #include <__memory/compressed_pair.h> |
24 #include <__memory/pointer_traits.h> | 24 #include <__memory/pointer_traits.h> |
25 #include <__memory/shared_ptr.h> | |
26 #include <__memory/swap_allocator.h> | 25 #include <__memory/swap_allocator.h> |
26 #include <__type_traits/add_lvalue_reference.h> | |
27 #include <__type_traits/enable_if.h> | |
28 #include <__type_traits/integral_constant.h> | |
29 #include <__type_traits/is_nothrow_default_constructible.h> | |
30 #include <__type_traits/is_nothrow_move_assignable.h> | |
31 #include <__type_traits/is_nothrow_move_constructible.h> | |
32 #include <__type_traits/is_swappable.h> | |
33 #include <__type_traits/is_trivially_destructible.h> | |
34 #include <__type_traits/remove_reference.h> | |
27 #include <__utility/forward.h> | 35 #include <__utility/forward.h> |
28 #include <__utility/move.h> | 36 #include <__utility/move.h> |
29 #include <type_traits> | 37 #include <cstddef> |
30 | 38 |
31 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 39 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
32 # pragma GCC system_header | 40 # pragma GCC system_header |
33 #endif | 41 #endif |
34 | 42 |
43 // it to grow both in the front and back without having to move the data. | 51 // it to grow both in the front and back without having to move the data. |
44 | 52 |
45 template <class _Tp, class _Allocator = allocator<_Tp> > | 53 template <class _Tp, class _Allocator = allocator<_Tp> > |
46 struct __split_buffer | 54 struct __split_buffer |
47 { | 55 { |
56 public: | |
57 using value_type = _Tp; | |
58 using allocator_type = _Allocator; | |
59 using __alloc_rr = __libcpp_remove_reference_t<allocator_type>; | |
60 using __alloc_traits = allocator_traits<__alloc_rr>; | |
61 using reference = value_type&; | |
62 using const_reference = const value_type&; | |
63 using size_type = typename __alloc_traits::size_type; | |
64 using difference_type = typename __alloc_traits::difference_type; | |
65 using pointer = typename __alloc_traits::pointer; | |
66 using const_pointer = typename __alloc_traits::const_pointer; | |
67 using iterator = pointer; | |
68 using const_iterator = const_pointer; | |
69 | |
70 pointer __first_; | |
71 pointer __begin_; | |
72 pointer __end_; | |
73 __compressed_pair<pointer, allocator_type> __end_cap_; | |
74 | |
75 using __alloc_ref = __add_lvalue_reference_t<allocator_type>; | |
76 using __alloc_const_ref = __add_lvalue_reference_t<allocator_type>; | |
77 | |
78 __split_buffer(const __split_buffer&) = delete; | |
79 __split_buffer& operator=(const __split_buffer&) = delete; | |
80 | |
81 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer() | |
82 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | |
83 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag()) {} | |
84 | |
85 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a) | |
86 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) {} | |
87 | |
88 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a) | |
89 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) {} | |
90 | |
91 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
92 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); | |
93 | |
94 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c) | |
95 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | |
96 | |
97 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); | |
98 | |
99 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c) | |
100 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && | |
101 is_nothrow_move_assignable<allocator_type>::value) || | |
102 !__alloc_traits::propagate_on_container_move_assignment::value); | |
103 | |
104 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer(); | |
105 | |
106 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __alloc_rr& __alloc() _NOEXCEPT { return __end_cap_.second(); } | |
107 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const __alloc_rr& __alloc() const _NOEXCEPT { | |
108 return __end_cap_.second(); | |
109 } | |
110 | |
111 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { return __end_cap_.first(); } | |
112 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT { | |
113 return __end_cap_.first(); | |
114 } | |
115 | |
116 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __begin_; } | |
117 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __begin_; } | |
118 | |
119 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __end_; } | |
120 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __end_; } | |
121 | |
122 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __destruct_at_end(__begin_); } | |
123 | |
124 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const { | |
125 return static_cast<size_type>(__end_ - __begin_); | |
126 } | |
127 | |
128 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __end_ == __begin_; } | |
129 | |
130 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const { | |
131 return static_cast<size_type>(__end_cap() - __first_); | |
132 } | |
133 | |
134 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const { | |
135 return static_cast<size_type>(__begin_ - __first_); | |
136 } | |
137 | |
138 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const { | |
139 return static_cast<size_type>(__end_cap() - __end_); | |
140 } | |
141 | |
142 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *__begin_; } | |
143 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const { return *__begin_; } | |
144 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() { return *(__end_ - 1); } | |
145 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return *(__end_ - 1); } | |
146 | |
147 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n); | |
148 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; | |
149 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(const_reference __x); | |
150 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x); | |
151 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x); | |
152 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); | |
153 | |
154 template <class... _Args> | |
155 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); | |
156 | |
157 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() { __destruct_at_begin(__begin_ + 1); } | |
158 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() { __destruct_at_end(__end_ - 1); } | |
159 | |
160 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); | |
161 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); | |
162 | |
163 template <class _InputIter> | |
164 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
165 __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value> | |
166 __construct_at_end(_InputIter __first, _InputIter __last); | |
167 | |
168 template <class _ForwardIterator> | |
169 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
170 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value> | |
171 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); | |
172 | |
173 template <class _Iterator, class _Sentinel> | |
174 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
175 void __construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last); | |
176 | |
177 template <class _Iterator> | |
178 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
179 void __construct_at_end_with_size(_Iterator __first, size_type __n); | |
180 | |
181 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin) { | |
182 __destruct_at_begin(__new_begin, is_trivially_destructible<value_type>()); | |
183 } | |
184 | |
185 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin, false_type); | |
186 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin, true_type); | |
187 | |
188 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT { | |
189 __destruct_at_end(__new_last, false_type()); | |
190 } | |
191 | |
192 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT; | |
193 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; | |
194 | |
195 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x) | |
196 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__alloc_rr>::value); | |
197 | |
198 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; | |
199 | |
48 private: | 200 private: |
49 __split_buffer(const __split_buffer&); | 201 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type) |
50 __split_buffer& operator=(const __split_buffer&); | 202 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { |
51 public: | 203 __alloc() = _VSTD::move(__c.__alloc()); |
52 typedef _Tp value_type; | 204 } |
53 typedef _Allocator allocator_type; | 205 |
54 typedef __libcpp_remove_reference_t<allocator_type> __alloc_rr; | 206 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {} |
55 typedef allocator_traits<__alloc_rr> __alloc_traits; | 207 |
56 typedef value_type& reference; | 208 struct _ConstructTransaction { |
57 typedef const value_type& const_reference; | 209 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction( |
58 typedef typename __alloc_traits::size_type size_type; | 210 pointer* __p, size_type __n) _NOEXCEPT |
59 typedef typename __alloc_traits::difference_type difference_type; | 211 : __pos_(*__p), |
60 typedef typename __alloc_traits::pointer pointer; | 212 __end_(*__p + __n), |
61 typedef typename __alloc_traits::const_pointer const_pointer; | 213 __dest_(__p) {} |
62 typedef pointer iterator; | 214 |
63 typedef const_pointer const_iterator; | 215 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { *__dest_ = __pos_; } |
64 | 216 |
65 pointer __first_; | 217 pointer __pos_; |
66 pointer __begin_; | 218 const pointer __end_; |
67 pointer __end_; | 219 |
68 __compressed_pair<pointer, allocator_type> __end_cap_; | 220 private: |
69 | 221 pointer* __dest_; |
70 typedef __add_lvalue_reference_t<allocator_type> __alloc_ref; | 222 }; |
71 typedef __add_lvalue_reference_t<allocator_type> __alloc_const_ref; | |
72 | |
73 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} | |
74 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} | |
75 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} | |
76 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} | |
77 | |
78 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
79 __split_buffer() | |
80 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | |
81 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
82 explicit __split_buffer(__alloc_rr& __a); | |
83 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
84 explicit __split_buffer(const __alloc_rr& __a); | |
85 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); | |
86 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer(); | |
87 | |
88 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c) | |
89 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | |
90 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); | |
91 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c) | |
92 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && | |
93 is_nothrow_move_assignable<allocator_type>::value) || | |
94 !__alloc_traits::propagate_on_container_move_assignment::value); | |
95 | |
96 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {return __begin_;} | |
97 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {return __begin_;} | |
98 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {return __end_;} | |
99 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {return __end_;} | |
100 | |
101 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
102 void clear() _NOEXCEPT | |
103 {__destruct_at_end(__begin_);} | |
104 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const {return static_cast<size_type>(__end_ - __begin_);} | |
105 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const {return __end_ == __begin_;} | |
106 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);} | |
107 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);} | |
108 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);} | |
109 | |
110 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() {return *__begin_;} | |
111 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const {return *__begin_;} | |
112 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() {return *(__end_ - 1);} | |
113 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const {return *(__end_ - 1);} | |
114 | |
115 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n); | |
116 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; | |
117 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(const_reference __x); | |
118 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x); | |
119 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x); | |
120 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); | |
121 template <class... _Args> | |
122 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); | |
123 | |
124 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() {__destruct_at_begin(__begin_+1);} | |
125 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() {__destruct_at_end(__end_-1);} | |
126 | |
127 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); | |
128 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); | |
129 template <class _InputIter> | |
130 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value> | |
131 __construct_at_end(_InputIter __first, _InputIter __last); | |
132 template <class _ForwardIterator> | |
133 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> | |
134 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); | |
135 | |
136 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin) | |
137 {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());} | |
138 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
139 void __destruct_at_begin(pointer __new_begin, false_type); | |
140 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
141 void __destruct_at_begin(pointer __new_begin, true_type); | |
142 | |
143 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
144 void __destruct_at_end(pointer __new_last) _NOEXCEPT | |
145 {__destruct_at_end(__new_last, false_type());} | |
146 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
147 void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT; | |
148 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
149 void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; | |
150 | |
151 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x) | |
152 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| | |
153 __is_nothrow_swappable<__alloc_rr>::value); | |
154 | |
155 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; | |
156 | |
157 private: | |
158 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
159 void __move_assign_alloc(__split_buffer& __c, true_type) | |
160 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | |
161 { | |
162 __alloc() = _VSTD::move(__c.__alloc()); | |
163 } | |
164 | |
165 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
166 void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT | |
167 {} | |
168 | |
169 struct _ConstructTransaction { | |
170 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT | |
171 : __pos_(*__p), __end_(*__p + __n), __dest_(__p) { | |
172 } | |
173 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { | |
174 *__dest_ = __pos_; | |
175 } | |
176 pointer __pos_; | |
177 const pointer __end_; | |
178 private: | |
179 pointer *__dest_; | |
180 }; | |
181 }; | 223 }; |
182 | 224 |
183 template <class _Tp, class _Allocator> | 225 template <class _Tp, class _Allocator> |
184 _LIBCPP_CONSTEXPR_SINCE_CXX20 | 226 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
185 bool | 227 bool |
240 } | 282 } |
241 } | 283 } |
242 | 284 |
243 template <class _Tp, class _Allocator> | 285 template <class _Tp, class _Allocator> |
244 template <class _InputIter> | 286 template <class _InputIter> |
245 _LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value> | 287 _LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value> |
246 __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) | 288 __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) |
247 { | 289 { |
290 __construct_at_end_with_sentinel(__first, __last); | |
291 } | |
292 | |
293 template <class _Tp, class _Allocator> | |
294 template <class _Iterator, class _Sentinel> | |
295 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
296 void __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) { | |
248 __alloc_rr& __a = this->__alloc(); | 297 __alloc_rr& __a = this->__alloc(); |
249 for (; __first != __last; ++__first) | 298 for (; __first != __last; ++__first) |
250 { | 299 { |
251 if (__end_ == __end_cap()) | 300 if (__end_ == __end_cap()) |
252 { | 301 { |
260 } | 309 } |
261 __alloc_traits::construct(__a, _VSTD::__to_address(this->__end_), *__first); | 310 __alloc_traits::construct(__a, _VSTD::__to_address(this->__end_), *__first); |
262 ++this->__end_; | 311 ++this->__end_; |
263 } | 312 } |
264 } | 313 } |
265 | |
266 template <class _Tp, class _Allocator> | 314 template <class _Tp, class _Allocator> |
267 template <class _ForwardIterator> | 315 template <class _ForwardIterator> |
268 _LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> | 316 _LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value> |
269 __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) | 317 __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) |
270 { | 318 { |
271 _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last)); | 319 __construct_at_end_with_size(__first, std::distance(__first, __last)); |
320 } | |
321 | |
322 template <class _Tp, class _Allocator> | |
323 template <class _ForwardIterator> | |
324 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
325 void __split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) { | |
326 _ConstructTransaction __tx(&this->__end_, __n); | |
272 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void) ++__first) { | 327 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void) ++__first) { |
273 __alloc_traits::construct(this->__alloc(), | 328 __alloc_traits::construct(this->__alloc(), |
274 _VSTD::__to_address(__tx.__pos_), *__first); | 329 _VSTD::__to_address(__tx.__pos_), *__first); |
275 } | 330 } |
276 } | 331 } |
325 __first_ = __allocation.ptr; | 380 __first_ = __allocation.ptr; |
326 __cap = __allocation.count; | 381 __cap = __allocation.count; |
327 } | 382 } |
328 __begin_ = __end_ = __first_ + __start; | 383 __begin_ = __end_ = __first_ + __start; |
329 __end_cap() = __first_ + __cap; | 384 __end_cap() = __first_ + __cap; |
330 } | |
331 | |
332 template <class _Tp, class _Allocator> | |
333 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
334 inline | |
335 __split_buffer<_Tp, _Allocator>::__split_buffer() | |
336 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | |
337 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag()) | |
338 { | |
339 } | |
340 | |
341 template <class _Tp, class _Allocator> | |
342 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
343 inline | |
344 __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) | |
345 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) | |
346 { | |
347 } | |
348 | |
349 template <class _Tp, class _Allocator> | |
350 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
351 inline | |
352 __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) | |
353 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) | |
354 { | |
355 } | 385 } |
356 | 386 |
357 template <class _Tp, class _Allocator> | 387 template <class _Tp, class _Allocator> |
358 _LIBCPP_CONSTEXPR_SINCE_CXX20 | 388 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
359 __split_buffer<_Tp, _Allocator>::~__split_buffer() | 389 __split_buffer<_Tp, _Allocator>::~__split_buffer() |
462 void | 492 void |
463 __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT | 493 __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT |
464 { | 494 { |
465 if (capacity() > size()) | 495 if (capacity() > size()) |
466 { | 496 { |
467 #ifndef _LIBCPP_NO_EXCEPTIONS | 497 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
468 try | 498 try |
469 { | 499 { |
470 #endif // _LIBCPP_NO_EXCEPTIONS | 500 #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
471 __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc()); | 501 __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc()); |
472 __t.__construct_at_end(move_iterator<pointer>(__begin_), | 502 __t.__construct_at_end(move_iterator<pointer>(__begin_), |
473 move_iterator<pointer>(__end_)); | 503 move_iterator<pointer>(__end_)); |
474 __t.__end_ = __t.__begin_ + (__end_ - __begin_); | 504 __t.__end_ = __t.__begin_ + (__end_ - __begin_); |
475 _VSTD::swap(__first_, __t.__first_); | 505 _VSTD::swap(__first_, __t.__first_); |
476 _VSTD::swap(__begin_, __t.__begin_); | 506 _VSTD::swap(__begin_, __t.__begin_); |
477 _VSTD::swap(__end_, __t.__end_); | 507 _VSTD::swap(__end_, __t.__end_); |
478 _VSTD::swap(__end_cap(), __t.__end_cap()); | 508 _VSTD::swap(__end_cap(), __t.__end_cap()); |
479 #ifndef _LIBCPP_NO_EXCEPTIONS | 509 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
480 } | 510 } |
481 catch (...) | 511 catch (...) |
482 { | 512 { |
483 } | 513 } |
484 #endif // _LIBCPP_NO_EXCEPTIONS | 514 #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
485 } | 515 } |
486 } | 516 } |
487 | 517 |
488 template <class _Tp, class _Allocator> | 518 template <class _Tp, class _Allocator> |
489 _LIBCPP_CONSTEXPR_SINCE_CXX20 | 519 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
499 __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); | 529 __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); |
500 __end_ += __d; | 530 __end_ += __d; |
501 } | 531 } |
502 else | 532 else |
503 { | 533 { |
504 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | 534 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); |
505 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc()); | 535 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc()); |
506 __t.__construct_at_end(move_iterator<pointer>(__begin_), | 536 __t.__construct_at_end(move_iterator<pointer>(__begin_), |
507 move_iterator<pointer>(__end_)); | 537 move_iterator<pointer>(__end_)); |
508 _VSTD::swap(__first_, __t.__first_); | 538 _VSTD::swap(__first_, __t.__first_); |
509 _VSTD::swap(__begin_, __t.__begin_); | 539 _VSTD::swap(__begin_, __t.__begin_); |
529 __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); | 559 __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); |
530 __end_ += __d; | 560 __end_ += __d; |
531 } | 561 } |
532 else | 562 else |
533 { | 563 { |
534 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | 564 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); |
535 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc()); | 565 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc()); |
536 __t.__construct_at_end(move_iterator<pointer>(__begin_), | 566 __t.__construct_at_end(move_iterator<pointer>(__begin_), |
537 move_iterator<pointer>(__end_)); | 567 move_iterator<pointer>(__end_)); |
538 _VSTD::swap(__first_, __t.__first_); | 568 _VSTD::swap(__first_, __t.__first_); |
539 _VSTD::swap(__begin_, __t.__begin_); | 569 _VSTD::swap(__begin_, __t.__begin_); |
561 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); | 591 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); |
562 __begin_ -= __d; | 592 __begin_ -= __d; |
563 } | 593 } |
564 else | 594 else |
565 { | 595 { |
566 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | 596 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); |
567 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); | 597 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); |
568 __t.__construct_at_end(move_iterator<pointer>(__begin_), | 598 __t.__construct_at_end(move_iterator<pointer>(__begin_), |
569 move_iterator<pointer>(__end_)); | 599 move_iterator<pointer>(__end_)); |
570 _VSTD::swap(__first_, __t.__first_); | 600 _VSTD::swap(__first_, __t.__first_); |
571 _VSTD::swap(__begin_, __t.__begin_); | 601 _VSTD::swap(__begin_, __t.__begin_); |
591 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); | 621 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); |
592 __begin_ -= __d; | 622 __begin_ -= __d; |
593 } | 623 } |
594 else | 624 else |
595 { | 625 { |
596 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | 626 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); |
597 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); | 627 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); |
598 __t.__construct_at_end(move_iterator<pointer>(__begin_), | 628 __t.__construct_at_end(move_iterator<pointer>(__begin_), |
599 move_iterator<pointer>(__end_)); | 629 move_iterator<pointer>(__end_)); |
600 _VSTD::swap(__first_, __t.__first_); | 630 _VSTD::swap(__first_, __t.__first_); |
601 _VSTD::swap(__begin_, __t.__begin_); | 631 _VSTD::swap(__begin_, __t.__begin_); |
623 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); | 653 __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); |
624 __begin_ -= __d; | 654 __begin_ -= __d; |
625 } | 655 } |
626 else | 656 else |
627 { | 657 { |
628 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | 658 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); |
629 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); | 659 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); |
630 __t.__construct_at_end(move_iterator<pointer>(__begin_), | 660 __t.__construct_at_end(move_iterator<pointer>(__begin_), |
631 move_iterator<pointer>(__end_)); | 661 move_iterator<pointer>(__end_)); |
632 _VSTD::swap(__first_, __t.__first_); | 662 _VSTD::swap(__first_, __t.__first_); |
633 _VSTD::swap(__begin_, __t.__begin_); | 663 _VSTD::swap(__begin_, __t.__begin_); |