diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -107,6 +107,8 @@ # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI +// Remove vector base class +# define _LIBCPP_ABI_NO_VECTOR_BASE_CLASS #elif _LIBCPP_ABI_VERSION == 1 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) // Enable compiling copies of now inline methods into the dylib to support diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -302,6 +302,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_ABI_NO_VECTOR_BASE_CLASS template struct __vector_base_common; @@ -315,42 +316,17 @@ template class __vector_base : protected __vector_base_common // This base class is historical, but it needs to remain for ABI compatibility -{ - typedef _Allocator allocator_type; - typedef typename allocator_traits::pointer pointer; - -protected: - pointer __begin_; - pointer __end_; - __compressed_pair __end_cap_; - - _LIBCPP_INLINE_VISIBILITY - __vector_base() - _NOEXCEPT_(is_nothrow_default_constructible::value) - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, __default_init_tag()) {} - - _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a) - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, __a) {} - -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, _VSTD::move(__a)) {} +{}; #endif -}; template */> class _LIBCPP_TEMPLATE_VIS vector +#ifndef _LIBCPP_ABI_NO_VECTOR_BASE_CLASS // This base class is historical, but it needs to remain for ABI compatibility. : private __vector_base<_Tp, _Allocator> +#endif { private: - typedef __vector_base<_Tp, _Allocator> __base; typedef allocator<_Tp> __default_allocator_type; public: typedef vector __self; @@ -382,7 +358,7 @@ #else _NOEXCEPT #endif - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); } @@ -394,7 +370,7 @@ template ::value> > vector(size_type __n, const value_type& __x, const allocator_type& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); if (__n > 0) @@ -691,6 +667,11 @@ #endif // _LIBCPP_DEBUG_LEVEL == 2 private: + pointer __begin_ = nullptr; + pointer __end_ = nullptr; + __compressed_pair __end_cap_ = + __compressed_pair(nullptr, allocator_type()); + _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); void __vallocate(size_type __n); @@ -859,20 +840,12 @@ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { -#ifndef _LIBCPP_NO_EXCEPTIONS - __vector_base_common::__throw_length_error(); -#else - _VSTD::abort(); -#endif + _VSTD::__throw_length_error("vector"); } _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { -#ifndef _LIBCPP_NO_EXCEPTIONS - __vector_base_common::__throw_out_of_range(); -#else - _VSTD::abort(); -#endif + _VSTD::__throw_out_of_range("vector"); } _LIBCPP_INLINE_VISIBILITY @@ -1106,7 +1079,7 @@ #if _LIBCPP_STD_VER > 11 template vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); if (__n > 0) @@ -1151,7 +1124,7 @@ is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value>::type*) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); for (; __first != __last; ++__first) @@ -1183,7 +1156,7 @@ is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value>::type*) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); size_type __n = static_cast(_VSTD::distance(__first, __last)); @@ -1196,7 +1169,7 @@ template vector<_Tp, _Allocator>::vector(const vector& __x) - : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) + : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) { _VSTD::__debug_db_insert_c(this); size_type __n = __x.size(); @@ -1209,7 +1182,7 @@ template vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); size_type __n = __x.size(); @@ -1230,7 +1203,7 @@ #else _NOEXCEPT_(is_nothrow_move_constructible::value) #endif - : __base(_VSTD::move(__x.__alloc())) + : __end_cap_(nullptr, _VSTD::move(__x.__alloc())) { _VSTD::__debug_db_insert_c(this); #if _LIBCPP_DEBUG_LEVEL == 2 @@ -1245,7 +1218,7 @@ template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); if (__a == __x.__alloc()) @@ -1280,7 +1253,7 @@ template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il, const allocator_type& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); if (__il.size() > 0) diff --git a/libcxx/src/vector.cpp b/libcxx/src/vector.cpp --- a/libcxx/src/vector.cpp +++ b/libcxx/src/vector.cpp @@ -10,6 +10,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_ABI_NO_VECTOR_BASE_CLASS + void __vector_base_common::__throw_length_error() const { _VSTD::__throw_length_error("vector"); } @@ -18,4 +20,6 @@ _VSTD::__throw_out_of_range("vector"); } +#endif + _LIBCPP_END_NAMESPACE_STD