@@ -152,6 +152,8 @@ public:
152
152
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front (value_type&& __x);
153
153
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back (value_type&& __x);
154
154
155
+ template <class ... _Args>
156
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_front (_Args&&... __args);
155
157
template <class ... _Args>
156
158
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back (_Args&&... __args);
157
159
@@ -456,28 +458,17 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fi
456
458
457
459
template <class _Tp , class _Allocator >
458
460
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front (const_reference __x) {
459
- if (__begin_ == __first_) {
460
- if (__end_ < __end_cap ()) {
461
- difference_type __d = __end_cap () - __end_;
462
- __d = (__d + 1 ) / 2 ;
463
- __begin_ = std::move_backward (__begin_, __end_, __end_ + __d);
464
- __end_ += __d;
465
- } else {
466
- size_type __c = std::max<size_type>(2 * static_cast <size_t >(__end_cap () - __first_), 1 );
467
- __split_buffer<value_type, __alloc_rr&> __t (__c, (__c + 3 ) / 4 , __alloc ());
468
- __t .__construct_at_end (move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
469
- std::swap (__first_, __t .__first_ );
470
- std::swap (__begin_, __t .__begin_ );
471
- std::swap (__end_, __t .__end_ );
472
- std::swap (__end_cap (), __t .__end_cap ());
473
- }
474
- }
475
- __alloc_traits::construct (__alloc (), std::__to_address (__begin_ - 1 ), __x);
476
- --__begin_;
461
+ emplace_front (__x);
477
462
}
478
463
479
464
template <class _Tp , class _Allocator >
480
465
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front (value_type&& __x) {
466
+ emplace_front (std::move (__x));
467
+ }
468
+
469
+ template <class _Tp , class _Allocator >
470
+ template <class ... _Args>
471
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_front (_Args&&... __args) {
481
472
if (__begin_ == __first_) {
482
473
if (__end_ < __end_cap ()) {
483
474
difference_type __d = __end_cap () - __end_;
@@ -494,53 +485,19 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front(v
494
485
std::swap (__end_cap (), __t .__end_cap ());
495
486
}
496
487
}
497
- __alloc_traits::construct (__alloc (), std::__to_address (__begin_ - 1 ), std::move (__x) );
488
+ __alloc_traits::construct (__alloc (), std::__to_address (__begin_ - 1 ), std::forward<_Args>(__args)... );
498
489
--__begin_;
499
490
}
500
491
501
492
template <class _Tp , class _Allocator >
502
493
_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
503
494
__split_buffer<_Tp, _Allocator>::push_back (const_reference __x) {
504
- if (__end_ == __end_cap ()) {
505
- if (__begin_ > __first_) {
506
- difference_type __d = __begin_ - __first_;
507
- __d = (__d + 1 ) / 2 ;
508
- __end_ = std::move (__begin_, __end_, __begin_ - __d);
509
- __begin_ -= __d;
510
- } else {
511
- size_type __c = std::max<size_type>(2 * static_cast <size_t >(__end_cap () - __first_), 1 );
512
- __split_buffer<value_type, __alloc_rr&> __t (__c, __c / 4 , __alloc ());
513
- __t .__construct_at_end (move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
514
- std::swap (__first_, __t .__first_ );
515
- std::swap (__begin_, __t .__begin_ );
516
- std::swap (__end_, __t .__end_ );
517
- std::swap (__end_cap (), __t .__end_cap ());
518
- }
519
- }
520
- __alloc_traits::construct (__alloc (), std::__to_address (__end_), __x);
521
- ++__end_;
495
+ emplace_back (__x);
522
496
}
523
497
524
498
template <class _Tp , class _Allocator >
525
499
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_back (value_type&& __x) {
526
- if (__end_ == __end_cap ()) {
527
- if (__begin_ > __first_) {
528
- difference_type __d = __begin_ - __first_;
529
- __d = (__d + 1 ) / 2 ;
530
- __end_ = std::move (__begin_, __end_, __begin_ - __d);
531
- __begin_ -= __d;
532
- } else {
533
- size_type __c = std::max<size_type>(2 * static_cast <size_t >(__end_cap () - __first_), 1 );
534
- __split_buffer<value_type, __alloc_rr&> __t (__c, __c / 4 , __alloc ());
535
- __t .__construct_at_end (move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
536
- std::swap (__first_, __t .__first_ );
537
- std::swap (__begin_, __t .__begin_ );
538
- std::swap (__end_, __t .__end_ );
539
- std::swap (__end_cap (), __t .__end_cap ());
540
- }
541
- }
542
- __alloc_traits::construct (__alloc (), std::__to_address (__end_), std::move (__x));
543
- ++__end_;
500
+ emplace_back (std::move (__x));
544
501
}
545
502
546
503
template <class _Tp , class _Allocator >
0 commit comments