@@ -2646,9 +2646,11 @@ private:
2646
2646
return;
2647
2647
}
2648
2648
2649
- _My_data._Myres = _BUF_SIZE - 1;
2650
- const size_type _New_capacity = _Calculate_growth(_Count);
2651
- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
2649
+ _My_data._Myres = _BUF_SIZE - 1;
2650
+ size_type _New_capacity = _Calculate_growth(_Count);
2651
+ ++_New_capacity;
2652
+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
2653
+ --_New_capacity;
2652
2654
_Construct_in_place(_My_data._Bx._Ptr, _New_ptr);
2653
2655
2654
2656
_Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
@@ -2690,8 +2692,10 @@ private:
2690
2692
}
2691
2693
2692
2694
if (_Count >= _BUF_SIZE) {
2693
- const size_type _New_capacity = _Calculate_growth(_Count);
2694
- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
2695
+ size_type _New_capacity = _Calculate_growth(_Count);
2696
+ ++_New_capacity;
2697
+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
2698
+ --_New_capacity;
2695
2699
_Construct_in_place(_My_data._Bx._Ptr, _New_ptr);
2696
2700
_My_data._Myres = _New_capacity;
2697
2701
@@ -2707,9 +2711,11 @@ private:
2707
2711
_Xlen_string(); // result too long
2708
2712
}
2709
2713
2710
- const auto _Old_ptr = _My_data._Myptr();
2711
- const size_type _New_capacity = _Calculate_growth(_My_data._Mysize);
2712
- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
2714
+ const auto _Old_ptr = _My_data._Myptr();
2715
+ size_type _New_capacity = _Calculate_growth(_My_data._Mysize);
2716
+ ++_New_capacity;
2717
+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
2718
+ --_New_capacity;
2713
2719
2714
2720
_Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
2715
2721
_Traits::copy(_Unfancy(_New_ptr), _Old_ptr, _My_data._Mysize);
@@ -2791,9 +2797,11 @@ public:
2791
2797
_Container_proxy_ptr<_Alty> _Proxy(_Alproxy, _My_data); // throws
2792
2798
2793
2799
if (_New_capacity < _New_size) {
2794
- _New_capacity = _Calculate_growth(_New_size, _BUF_SIZE - 1, max_size());
2795
- const pointer _Fancyptr = _Getal().allocate(_New_capacity + 1); // throws
2796
- _Ptr = _Unfancy(_Fancyptr);
2800
+ _New_capacity = _Calculate_growth(_New_size, _BUF_SIZE - 1, max_size());
2801
+ ++_New_capacity;
2802
+ const pointer _Fancyptr = _Allocate_at_least_helper(_Getal(), _New_capacity); // throws
2803
+ --_New_capacity;
2804
+ _Ptr = _Unfancy(_Fancyptr);
2797
2805
_Construct_in_place(_My_data._Bx._Ptr, _Fancyptr);
2798
2806
2799
2807
_Start_element_lifetimes(_Ptr, _New_capacity + 1);
@@ -2862,10 +2870,12 @@ public:
2862
2870
_Xlen_string();
2863
2871
}
2864
2872
2865
- const auto _New_capacity = _Calculate_growth(_New_size, _BUF_SIZE - 1, _Max);
2866
- auto&& _Alproxy = _GET_PROXY_ALLOCATOR(_Alty, _Getal());
2873
+ auto _New_capacity = _Calculate_growth(_New_size, _BUF_SIZE - 1, _Max);
2874
+ auto&& _Alproxy = _GET_PROXY_ALLOCATOR(_Alty, _Getal());
2867
2875
_Container_proxy_ptr<_Alty> _Proxy(_Alproxy, _My_data); // throws
2868
- const pointer _Fancyptr = _Getal().allocate(_New_capacity + 1); // throws
2876
+ ++_New_capacity;
2877
+ const pointer _Fancyptr = _Allocate_at_least_helper(_Getal(), _New_capacity); // throws
2878
+ --_New_capacity;
2869
2879
// nothrow hereafter
2870
2880
_Start_element_lifetimes(_Unfancy(_Fancyptr), _New_capacity + 1);
2871
2881
_Construct_in_place(_My_data._Bx._Ptr, _Fancyptr);
@@ -2945,9 +2955,10 @@ public:
2945
2955
_Result._Res = _My_data._Myres + 1;
2946
2956
} else {
2947
2957
// use _BUF_SIZE + 1 to avoid SSO, if the buffer is assigned back
2948
- _Result._Ptr = _Al.allocate(_BUF_SIZE + 1);
2958
+ size_type _Allocated = _BUF_SIZE + 1;
2959
+ _Result._Ptr = _Allocate_at_least_helper(_Al, _Allocated);
2949
2960
_Traits::copy(_Unfancy(_Result._Ptr), _My_data._Bx._Buf, _BUF_SIZE);
2950
- _Result._Res = _BUF_SIZE + 1 ;
2961
+ _Result._Res = _Allocated ;
2951
2962
}
2952
2963
_My_data._Orphan_all();
2953
2964
_Tidy_init();
@@ -3166,11 +3177,13 @@ public:
3166
3177
3167
3178
if (_Right._Mypair._Myval2._Large_string_engaged()) {
3168
3179
const auto _New_size = _Right._Mypair._Myval2._Mysize;
3169
- const auto _New_capacity = _Calculate_growth(_New_size, 0, _Right.max_size());
3180
+ auto _New_capacity = _Calculate_growth(_New_size, 0, _Right.max_size());
3170
3181
auto _Right_al_non_const = _Right_al;
3171
- const auto _New_ptr = _Right_al_non_const.allocate(_New_capacity + 1); // throws
3182
+ ++_New_capacity;
3183
+ const auto _New_ptr = _Allocate_at_least_helper(_Right_al_non_const, _New_capacity); // throws
3184
+ --_New_capacity;
3172
3185
3173
- _Start_element_lifetimes(_Unfancy(_New_ptr), _New_size + 1);
3186
+ _Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
3174
3187
3175
3188
_Traits::copy(_Unfancy(_New_ptr), _Unfancy(_Right._Mypair._Myval2._Bx._Ptr), _New_size + 1);
3176
3189
_Tidy_deallocate();
@@ -4735,9 +4748,11 @@ private:
4735
4748
}
4736
4749
4737
4750
const size_type _Old_capacity = _Mypair._Myval2._Myres;
4738
- const size_type _New_capacity = _Calculate_growth(_New_size);
4751
+ size_type _New_capacity = _Calculate_growth(_New_size);
4739
4752
auto& _Al = _Getal();
4740
- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
4753
+ ++_New_capacity;
4754
+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
4755
+ --_New_capacity;
4741
4756
4742
4757
_Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
4743
4758
_Mypair._Myval2._Orphan_all();
@@ -4768,9 +4783,11 @@ private:
4768
4783
4769
4784
const size_type _New_size = _Old_size + _Size_increase;
4770
4785
const size_type _Old_capacity = _My_data._Myres;
4771
- const size_type _New_capacity = _Calculate_growth(_New_size);
4786
+ size_type _New_capacity = _Calculate_growth(_New_size);
4772
4787
auto& _Al = _Getal();
4773
- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
4788
+ ++_New_capacity;
4789
+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
4790
+ --_New_capacity;
4774
4791
4775
4792
_Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
4776
4793
_My_data._Orphan_all();
0 commit comments