@@ -138,30 +138,30 @@ struct _Identity {
138138template <class _Ty >
139139using identity_t = typename _Identity<_Ty>::type;
140140
141- template <class Alloc >
141+ template <class _Alloc >
142142class __uninitialized_backout_al {
143143public:
144- using allocator_traits = typename std::allocator_traits<Alloc >;
145- using pointer = typename allocator_traits::pointer;
146- using value_type = typename allocator_traits::value_type;
144+ using allocator_traits = typename std::allocator_traits<_Alloc >;
145+ using pointer = typename allocator_traits::pointer;
146+ using value_type = typename allocator_traits::value_type;
147147
148- __uninitialized_backout_al (pointer dest, Alloc & al) : _dest(dest), _cur(dest), _alloc(al), _released(false ) {}
148+ __uninitialized_backout_al (pointer dest, _Alloc & al) : _dest(dest), _cur(dest), _alloc(al), _released(false ) {}
149149
150150 ~__uninitialized_backout_al ()
151151 {
152152 if (!_released)
153153 {
154154 for (auto p = _dest; p != _cur; ++p)
155155 {
156- std::allocator_traits<Alloc >::destroy (_alloc, p);
156+ std::allocator_traits<_Alloc >::destroy (_alloc, p);
157157 }
158158 }
159159 }
160160
161161 template <class ... Args>
162162 void _Emplace_back (Args&&... args)
163163 {
164- std::allocator_traits<Alloc >::construct (_alloc, _cur, std::forward<Args>(args)...);
164+ std::allocator_traits<_Alloc >::construct (_alloc, _cur, std::forward<Args>(args)...);
165165 ++_cur;
166166 }
167167
@@ -174,34 +174,34 @@ class __uninitialized_backout_al {
174174private:
175175 pointer _dest;
176176 pointer _cur;
177- Alloc & _alloc;
177+ _Alloc & _alloc;
178178 bool _released;
179179};
180180
181181struct __value_init_tag { // tag to request value-initialization
182182 explicit __value_init_tag () = default;
183183};
184184
185- template <class Iter >
186- using iter_ref_t = typename std::iterator_traits<Iter >::reference;
185+ template <typename _Iter >
186+ using iter_ref_t = typename std::iterator_traits<_Iter >::reference;
187187
188188inline void __xlength_error (const char * what) { throw ::std::length_error (what); }
189189
190190inline void __xout_of_range (const char * what) { throw ::std::out_of_range (what); }
191191
192192static_assert (std::is_same_v<typename std::iterator_traits<int *>::value_type, int >);
193193
194- template <class Iter >
195- inline constexpr bool is_pod_iterator_v = std::is_trivially_copyable_v<typename std::iterator_traits<Iter >::value_type>;
194+ template <typename _Iter >
195+ inline constexpr bool is_pod_iterator_v = std::is_trivially_copyable_v<typename std::iterator_traits<_Iter >::value_type>;
196196
197- template <class Iter , class Ptr >
198- inline constexpr bool bitcopy_assignable_v = std::is_trivially_copyable_v<typename std::iterator_traits<Iter >::value_type> &&
199- std::is_same_v<typename std::iterator_traits<Iter >::value_type, typename std::pointer_traits<Ptr >::element_type>;
197+ template <typename _Iter, typename _Ptr >
198+ inline constexpr bool bitcopy_assignable_v = std::is_trivially_copyable_v<typename std::iterator_traits<_Iter >::value_type> &&
199+ std::is_same_v<typename std::iterator_traits<_Iter >::value_type, typename std::pointer_traits<_Ptr >::element_type>;
200200
201- template <class Alloc >
202- typename Alloc::pointer uninitialized_fill_n (typename Alloc::pointer first, size_t count, const typename Alloc ::value_type& val, Alloc & alloc)
201+ template <typename _Ptr, typename _Alloc >
202+ _Ptr uninitialized_fill_n (_Ptr first, size_t count, const typename _Alloc ::value_type& val, _Alloc & alloc)
203203{
204- using T = typename Alloc ::value_type;
204+ using T = typename _Alloc ::value_type;
205205
206206 if constexpr (std::is_trivially_copyable_v<T>)
207207 {
@@ -215,16 +215,16 @@ typename Alloc::pointer uninitialized_fill_n(typename Alloc::pointer first, size
215215 {
216216 for (size_t i = 0 ; i < count; ++i)
217217 {
218- std::allocator_traits<Alloc >::construct (alloc, first + i, val);
218+ std::allocator_traits<_Alloc >::construct (alloc, first + i, val);
219219 }
220220 return first + count;
221221 }
222222}
223223
224- template <class InIt , class OutPtr , class Alloc >
225- constexpr OutPtr uninitialized_move (InIt first, InIt last, OutPtr dest, Alloc & alloc)
224+ template <typename _InIt, typename _OutPtr, typename _Alloc >
225+ constexpr _OutPtr uninitialized_move (_InIt first, _InIt last, _OutPtr dest, _Alloc & alloc)
226226{
227- using T = typename Alloc ::value_type;
227+ using T = typename _Alloc ::value_type;
228228 const auto count = static_cast <size_t >(last - first);
229229
230230 if constexpr (std::is_trivially_copyable_v<T>)
@@ -236,18 +236,18 @@ constexpr OutPtr uninitialized_move(InIt first, InIt last, OutPtr dest, Alloc& a
236236 }
237237 }
238238
239- __uninitialized_backout_al<Alloc > backout{dest, alloc};
239+ __uninitialized_backout_al<_Alloc > backout{dest, alloc};
240240 for (; first != last; ++first)
241241 {
242242 backout._Emplace_back (std::move (*first));
243243 }
244244 return backout._Release ();
245245}
246246
247- template <class InIt , class Alloc , class OutPtr >
248- constexpr OutPtr uninitialized_copy_n (InIt first, size_t count, OutPtr dest, Alloc & alloc)
247+ template <typename _InIt, typename _Alloc, typename _OutPtr >
248+ constexpr _OutPtr uninitialized_copy_n (_InIt first, size_t count, _OutPtr dest, _Alloc & alloc)
249249{
250- using T = typename Alloc ::value_type;
250+ using T = typename _Alloc ::value_type;
251251
252252 if constexpr (std::is_trivially_copyable_v<T>)
253253 {
@@ -256,7 +256,7 @@ constexpr OutPtr uninitialized_copy_n(InIt first, size_t count, OutPtr dest, All
256256 }
257257 else
258258 {
259- __uninitialized_backout_al<Alloc > backout{dest, alloc};
259+ __uninitialized_backout_al<_Alloc > backout{dest, alloc};
260260 for (; count != 0 ; ++first, --count)
261261 {
262262 backout._Emplace_back (*first);
@@ -265,10 +265,10 @@ constexpr OutPtr uninitialized_copy_n(InIt first, size_t count, OutPtr dest, All
265265 }
266266}
267267
268- template <class InIt , class Alloc >
269- typename Alloc::pointer uninitialized_copy (InIt first, InIt last, typename Alloc::pointer dest, Alloc & alloc)
268+ template <typename _InIt, typename _Ptr, typename _Alloc >
269+ _Ptr uninitialized_copy (_InIt first, _InIt last, _Ptr dest, _Alloc & alloc)
270270{
271- using T = typename Alloc ::value_type;
271+ using T = typename _Alloc ::value_type;
272272
273273 const auto count = static_cast <size_t >(last - first);
274274
@@ -279,7 +279,7 @@ typename Alloc::pointer uninitialized_copy(InIt first, InIt last, typename Alloc
279279 }
280280 else
281281 {
282- __uninitialized_backout_al<Alloc > backout{dest, alloc};
282+ __uninitialized_backout_al<_Alloc > backout{dest, alloc};
283283 for (; first != last; ++first)
284284 {
285285 backout._Emplace_back (*first);
@@ -288,33 +288,37 @@ typename Alloc::pointer uninitialized_copy(InIt first, InIt last, typename Alloc
288288 }
289289}
290290
291- template <class Alloc , class Ptr >
292- constexpr void destroy_range (Ptr first, Ptr last, Alloc & alloc) noexcept
291+ template <typename _Alloc, typename Ptr>
292+ constexpr void destroy_range (Ptr first, Ptr last, _Alloc & alloc) noexcept
293293{
294- using T = typename Alloc ::value_type;
294+ using T = typename _Alloc ::value_type;
295295
296296 if constexpr (!std::is_trivially_destructible_v<T>)
297297 {
298298 for (; first != last; ++first)
299299 {
300- std::allocator_traits<Alloc >::destroy (alloc, std::to_address (first));
300+ std::allocator_traits<_Alloc >::destroy (alloc, std::to_address (first));
301301 }
302302 }
303303}
304304
305- template <class Alloc >
306- typename Alloc::pointer uninitialized_value_construct_n (typename Alloc::pointer first, size_t count, Alloc& alloc)
305+ /*
306+ * trivially_constructible types: Use memset to zero for
307+ * non-trivially_constructible types: default constructor
308+ */
309+ template <typename _Ptr, typename _Alloc>
310+ _Ptr uninitialized_value_construct_n (_Ptr first, size_t count, _Alloc& alloc)
307311{
308- using T = typename Alloc ::value_type;
312+ using T = typename _Alloc ::value_type;
309313
310- if constexpr (std::is_trivially_constructible_v<T> && std::is_trivially_destructible_v<T> )
314+ if constexpr (std::is_trivially_constructible_v<T>)
311315 {
312316 ::memset (first, 0 , count * sizeof (T));
313317 return first + count;
314318 }
315319 else
316320 {
317- __uninitialized_backout_al<Alloc > backout{first, alloc};
321+ __uninitialized_backout_al<_Alloc > backout{first, alloc};
318322 for (; count > 0 ; --count)
319323 {
320324 backout._Emplace_back ();
@@ -323,7 +327,7 @@ typename Alloc::pointer uninitialized_value_construct_n(typename Alloc::pointer
323327 }
324328}
325329
326- template <class InCtgIt , class OutCtgIt >
330+ template <typename InCtgIt, typename OutCtgIt>
327331OutCtgIt copy_memmove_n (InCtgIt first, size_t count, OutCtgIt dest)
328332{
329333 using T = typename std::iterator_traits<InCtgIt>::value_type;
@@ -345,10 +349,10 @@ OutCtgIt copy_memmove_n(InCtgIt first, size_t count, OutCtgIt dest)
345349 }
346350}
347351
348- template <class InIt , class OutIt >
349- constexpr OutIt move_unchecked (InIt first, InIt last, OutIt dest)
352+ template <typename _InIt, typename _OutIt >
353+ constexpr _OutIt move_unchecked (_InIt first, _InIt last, _OutIt dest)
350354{
351- using T = typename std::iterator_traits<InIt >::value_type;
355+ using T = typename std::iterator_traits<_InIt >::value_type;
352356 const auto count = static_cast <size_t >(last - first);
353357
354358 if constexpr (std::is_trivially_copyable_v<T>)
@@ -366,7 +370,7 @@ constexpr OutIt move_unchecked(InIt first, InIt last, OutIt dest)
366370 }
367371}
368372
369- template <class _CtgIt1 , class _CtgIt2 >
373+ template <typename _CtgIt1, typename _CtgIt2>
370374_CtgIt2 copy_backward_memmove (_CtgIt1 _First, _CtgIt1 _Last, _CtgIt2 _Dest)
371375{
372376 // implement copy_backward-like function as memmove
@@ -392,13 +396,13 @@ _CtgIt2 copy_backward_memmove(_CtgIt1 _First, _CtgIt1 _Last, _CtgIt2 _Dest)
392396 }
393397}
394398
395- template <class _BidIt1 , class _BidIt2 >
399+ template <typename _BidIt1, typename _BidIt2>
396400_BidIt2 copy_backward_memmove (std::move_iterator<_BidIt1> _First, std::move_iterator<_BidIt1> _Last, _BidIt2 _Dest)
397401{
398402 return copy_backward_memmove (_First.base (), _Last.base (), _Dest);
399403}
400404
401- template <class _BidIt1 , class _BidIt2 >
405+ template <typename _BidIt1, typename _BidIt2>
402406_BidIt2 move_backward_unchecked (_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest)
403407{
404408 // move [_First, _Last) backwards to [..., _Dest)
@@ -419,12 +423,12 @@ _BidIt2 move_backward_unchecked(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest)
419423 return _Dest;
420424}
421425
422- template <class InIt , class SizeTy , class OutIt >
423- constexpr OutIt copy_n_unchecked4 (InIt first, SizeTy count, OutIt dest)
426+ template <typename _InIt, typename _SizeTy, typename _OutIt >
427+ constexpr _OutIt copy_n_unchecked4 (_InIt first, _SizeTy count, _OutIt dest)
424428{
425- using T = typename std::iterator_traits<InIt >::value_type;
429+ using T = typename std::iterator_traits<_InIt >::value_type;
426430
427- static_assert (std::is_integral_v<SizeTy >, " SizeTy must be integer-like" );
431+ static_assert (std::is_integral_v<_SizeTy >, " must be integer-like" );
428432 if (count < 0 )
429433 return dest;
430434
@@ -444,7 +448,7 @@ constexpr OutIt copy_n_unchecked4(InIt first, SizeTy count, OutIt dest)
444448 return dest;
445449}
446450
447- } // namespace yasio
451+ } // namespace tlx
448452
449453#define _TLX_VERIFY_RANGE (cond, mesg ) \
450454 do \
0 commit comments