@@ -1625,6 +1625,19 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void
1625
1625
vector<_Tp, _Allocator>::__move_range (pointer __from_s, pointer __from_e, pointer __to) {
1626
1626
pointer __old_last = this ->__end_ ;
1627
1627
difference_type __n = __old_last - __to;
1628
+
1629
+ #if _LIBCPP_STD_VER >= 26
1630
+ if ! consteval {
1631
+ if constexpr (is_trivially_relocatable_v<_Tp> || is_nothrow_move_constructible_v<_Tp>) {
1632
+ const size_t __numSpaces = __to - __from_s;
1633
+ _ConstructTransaction __tx (*this , __numSpaces);
1634
+ (void ) relocate (std::__to_address (__from_s), std::__to_address (__from_e), std::__to_address (__to));
1635
+ __tx.__pos_ += __numSpaces;
1636
+ return ;
1637
+ }
1638
+ }
1639
+ #endif
1640
+
1628
1641
{
1629
1642
pointer __i = __from_s + __n;
1630
1643
_ConstructTransaction __tx (*this , __from_e - __i);
@@ -1643,23 +1656,6 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
1643
1656
if (__p == this ->__end_ ) {
1644
1657
__construct_one_at_end (__x);
1645
1658
} else {
1646
- #if _LIBCPP_STD_VER >= 26
1647
- if constexpr (is_trivially_relocatable_v<_Tp> || is_nothrow_move_constructible_v<_Tp>) {
1648
- // Make space by trivially relocating everything
1649
- _ConstructTransaction __tx (*this , 1 );
1650
- (void ) relocate (std::__to_address (__p), std::__to_address (this ->__end_ ), std::__to_address (__p + 1 ));
1651
- // construct the new element (not assign!)
1652
- const_pointer __xr = pointer_traits<const_pointer>::pointer_to (__x);
1653
- if (std::__is_pointer_in_range (std::__to_address (__p), std::__to_address (__end_), std::addressof (__x)))
1654
- ++__xr;
1655
- __alloc_traits::construct (this ->__alloc (), std::__to_address (__p), *__xr);
1656
- ++__tx.__pos_ ;
1657
- // Need to fix up upon an exception!
1658
- // update all the invariants.
1659
- // return an iterator to the new entry
1660
- return __make_iter (__p);
1661
- }
1662
- #endif
1663
1659
__move_range (__p, this ->__end_ , __p + 1 );
1664
1660
const_pointer __xr = pointer_traits<const_pointer>::pointer_to (__x);
1665
1661
if (std::__is_pointer_in_range (std::__to_address (__p), std::__to_address (__end_), std::addressof (__x)))
@@ -1683,20 +1679,6 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {
1683
1679
if (__p == this ->__end_ ) {
1684
1680
__construct_one_at_end (std::move (__x));
1685
1681
} else {
1686
- #if _LIBCPP_STD_VER >= 26
1687
- if constexpr (is_trivially_relocatable_v<_Tp> || is_nothrow_move_constructible_v<_Tp>) {
1688
- // Make space by trivially relocating everything
1689
- _ConstructTransaction __tx (*this , 1 );
1690
- (void ) relocate (std::__to_address (__p), std::__to_address (this ->__end_ ), std::__to_address (__p + 1 ));
1691
- // construct the new element (not assign!)
1692
- __alloc_traits::construct (this ->__alloc (), std::__to_address (__p), std::forward<value_type>(__x));
1693
- ++__tx.__pos_ ;
1694
- // Need to fix up upon an exception!
1695
- // update all the invariants.
1696
- // return an iterator to the new entry
1697
- return __make_iter (__p);
1698
- }
1699
- #endif
1700
1682
__move_range (__p, this ->__end_ , __p + 1 );
1701
1683
*__p = std::move (__x);
1702
1684
}
@@ -1718,20 +1700,6 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
1718
1700
if (__p == this ->__end_ ) {
1719
1701
__construct_one_at_end (std::forward<_Args>(__args)...);
1720
1702
} else {
1721
- #if _LIBCPP_STD_VER >= 26
1722
- if constexpr (is_trivially_relocatable_v<_Tp> || is_nothrow_move_constructible_v<_Tp>) {
1723
- // Make space by trivially relocating everything
1724
- _ConstructTransaction __tx (*this , 1 );
1725
- (void ) relocate (std::__to_address (__p), std::__to_address (this ->__end_ ), std::__to_address (__p + 1 ));
1726
- // construct the new element
1727
- __alloc_traits::construct (this ->__alloc (), std::__to_address (__p), std::forward<_Args>(__args)...);
1728
- ++__tx.__pos_ ;
1729
- // Need to fix up upon an exception!
1730
- // update all the invariants.
1731
- // return an iterator to the new entry
1732
- return __make_iter (__p);
1733
- }
1734
- #endif
1735
1703
__temp_value<value_type, _Allocator> __tmp (this ->__alloc (), std::forward<_Args>(__args)...);
1736
1704
__move_range (__p, this ->__end_ , __p + 1 );
1737
1705
*__p = std::move (__tmp.get ());
0 commit comments