@@ -302,55 +302,10 @@ _LIBCPP_PUSH_MACROS
302
302
303
303
_LIBCPP_BEGIN_NAMESPACE_STD
304
304
305
- template <bool >
306
- struct __vector_base_common ;
307
-
308
- template <>
309
- struct __vector_base_common <true > {
310
- // Both are defined in vector.cpp
311
- _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error () const ;
312
- _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range () const ;
313
- };
314
-
315
- template <class _Tp , class _Allocator >
316
- class __vector_base
317
- : protected __vector_base_common<true > // This base class is historical, but it needs to remain for ABI compatibility
318
- {
319
- typedef _Allocator allocator_type;
320
- typedef typename allocator_traits<allocator_type>::pointer pointer;
321
-
322
- protected:
323
- pointer __begin_;
324
- pointer __end_;
325
- __compressed_pair<pointer, allocator_type> __end_cap_;
326
-
327
- _LIBCPP_INLINE_VISIBILITY
328
- __vector_base ()
329
- _NOEXCEPT_ (is_nothrow_default_constructible<allocator_type>::value)
330
- : __begin_(nullptr ),
331
- __end_ (nullptr ),
332
- __end_cap_(nullptr , __default_init_tag()) {}
333
-
334
- _LIBCPP_INLINE_VISIBILITY __vector_base (const allocator_type& __a)
335
- : __begin_(nullptr ),
336
- __end_(nullptr ),
337
- __end_cap_(nullptr , __a) {}
338
-
339
- #ifndef _LIBCPP_CXX03_LANG
340
- _LIBCPP_INLINE_VISIBILITY __vector_base (allocator_type&& __a) _NOEXCEPT
341
- : __begin_(nullptr ),
342
- __end_(nullptr ),
343
- __end_cap_(nullptr , _VSTD::move(__a)) {}
344
- #endif
345
- };
346
-
347
305
template <class _Tp , class _Allocator /* = allocator<_Tp> */ >
348
306
class _LIBCPP_TEMPLATE_VIS vector
349
- // This base class is historical, but it needs to remain for ABI compatibility.
350
- : private __vector_base<_Tp, _Allocator>
351
307
{
352
308
private:
353
- typedef __vector_base<_Tp, _Allocator> __base;
354
309
typedef allocator<_Tp> __default_allocator_type;
355
310
public:
356
311
typedef vector __self;
@@ -382,7 +337,7 @@ public:
382
337
#else
383
338
_NOEXCEPT
384
339
#endif
385
- : __base( __a)
340
+ : __end_cap_( nullptr , __a)
386
341
{
387
342
_VSTD::__debug_db_insert_c (this );
388
343
}
@@ -394,7 +349,7 @@ public:
394
349
395
350
template <class = __enable_if_t <__is_allocator<_Allocator>::value> >
396
351
vector (size_type __n, const value_type& __x, const allocator_type& __a)
397
- : __base( __a)
352
+ : __end_cap_( nullptr , __a)
398
353
{
399
354
_VSTD::__debug_db_insert_c (this );
400
355
if (__n > 0 )
@@ -691,6 +646,11 @@ public:
691
646
#endif // _LIBCPP_DEBUG_LEVEL == 2
692
647
693
648
private:
649
+ pointer __begin_ = nullptr ;
650
+ pointer __end_ = nullptr ;
651
+ __compressed_pair<pointer, allocator_type> __end_cap_ =
652
+ __compressed_pair<pointer, allocator_type>(nullptr , __default_init_tag());
653
+
694
654
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators ();
695
655
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past (pointer __new_last);
696
656
void __vallocate (size_type __n);
@@ -859,20 +819,12 @@ private:
859
819
860
820
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
861
821
void __throw_length_error () const {
862
- #ifndef _LIBCPP_NO_EXCEPTIONS
863
- __vector_base_common<true >::__throw_length_error ();
864
- #else
865
- _VSTD::abort ();
866
- #endif
822
+ _VSTD::__throw_length_error (" vector" );
867
823
}
868
824
869
825
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
870
826
void __throw_out_of_range () const {
871
- #ifndef _LIBCPP_NO_EXCEPTIONS
872
- __vector_base_common<true >::__throw_out_of_range ();
873
- #else
874
- _VSTD::abort ();
875
- #endif
827
+ _VSTD::__throw_out_of_range (" vector" );
876
828
}
877
829
878
830
_LIBCPP_INLINE_VISIBILITY
@@ -1106,7 +1058,7 @@ vector<_Tp, _Allocator>::vector(size_type __n)
1106
1058
#if _LIBCPP_STD_VER > 11
1107
1059
template <class _Tp , class _Allocator >
1108
1060
vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
1109
- : __base( __a)
1061
+ : __end_cap_( nullptr , __a)
1110
1062
{
1111
1063
_VSTD::__debug_db_insert_c (this );
1112
1064
if (__n > 0 )
@@ -1151,7 +1103,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
1151
1103
is_constructible<
1152
1104
value_type,
1153
1105
typename iterator_traits<_InputIterator>::reference>::value>::type*)
1154
- : __base( __a)
1106
+ : __end_cap_( nullptr , __a)
1155
1107
{
1156
1108
_VSTD::__debug_db_insert_c (this );
1157
1109
for (; __first != __last; ++__first)
@@ -1183,7 +1135,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
1183
1135
is_constructible<
1184
1136
value_type,
1185
1137
typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
1186
- : __base( __a)
1138
+ : __end_cap_( nullptr , __a)
1187
1139
{
1188
1140
_VSTD::__debug_db_insert_c (this );
1189
1141
size_type __n = static_cast <size_type>(_VSTD::distance (__first, __last));
@@ -1196,7 +1148,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
1196
1148
1197
1149
template <class _Tp , class _Allocator >
1198
1150
vector<_Tp, _Allocator>::vector(const vector& __x)
1199
- : __base( __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
1151
+ : __end_cap_( nullptr , __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
1200
1152
{
1201
1153
_VSTD::__debug_db_insert_c (this );
1202
1154
size_type __n = __x.size ();
@@ -1209,7 +1161,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
1209
1161
1210
1162
template <class _Tp , class _Allocator >
1211
1163
vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t <allocator_type>& __a)
1212
- : __base( __a)
1164
+ : __end_cap_( nullptr , __a)
1213
1165
{
1214
1166
_VSTD::__debug_db_insert_c (this );
1215
1167
size_type __n = __x.size ();
@@ -1230,7 +1182,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
1230
1182
#else
1231
1183
_NOEXCEPT_ (is_nothrow_move_constructible<allocator_type>::value)
1232
1184
#endif
1233
- : __base( _VSTD::move(__x.__alloc()))
1185
+ : __end_cap_( nullptr , _VSTD::move(__x.__alloc()))
1234
1186
{
1235
1187
_VSTD::__debug_db_insert_c (this );
1236
1188
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -1245,7 +1197,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
1245
1197
template <class _Tp , class _Allocator >
1246
1198
inline _LIBCPP_INLINE_VISIBILITY
1247
1199
vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t <allocator_type>& __a)
1248
- : __base( __a)
1200
+ : __end_cap_( nullptr , __a)
1249
1201
{
1250
1202
_VSTD::__debug_db_insert_c (this );
1251
1203
if (__a == __x.__alloc ())
@@ -1280,7 +1232,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
1280
1232
template <class _Tp , class _Allocator >
1281
1233
inline _LIBCPP_INLINE_VISIBILITY
1282
1234
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
1283
- : __base( __a)
1235
+ : __end_cap_( nullptr , __a)
1284
1236
{
1285
1237
_VSTD::__debug_db_insert_c (this );
1286
1238
if (__il.size () > 0 )
@@ -2079,7 +2031,6 @@ struct __has_storage_type<vector<bool, _Allocator> >
2079
2031
2080
2032
template <class _Allocator >
2081
2033
class _LIBCPP_TEMPLATE_VIS vector<bool , _Allocator>
2082
- : private __vector_base_common<true >
2083
2034
{
2084
2035
public:
2085
2036
typedef vector __self;
@@ -2348,6 +2299,16 @@ public:
2348
2299
bool __invariants () const ;
2349
2300
2350
2301
private:
2302
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
2303
+ void __throw_length_error () const {
2304
+ _VSTD::__throw_length_error (" vector" );
2305
+ }
2306
+
2307
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
2308
+ void __throw_out_of_range () const {
2309
+ _VSTD::__throw_out_of_range (" vector" );
2310
+ }
2311
+
2351
2312
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators ();
2352
2313
void __vallocate (size_type __n);
2353
2314
void __vdeallocate () _NOEXCEPT;
0 commit comments