[libcxx-commits] [libcxx] [libc++] Granularize <vector> (PR #99705)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 1 09:09:09 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
| | old time | new time |
| ------------------ | -------- | -------- |
| functional - c++23 | 416ms | 225ms |
| random - c++23 | 513ms | 392ms |
| vector - c++17 | 206ms | 100ms |
---
Patch is 247.63 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/99705.diff
37 Files Affected:
- (modified) libcxx/include/CMakeLists.txt (+7)
- (modified) libcxx/include/__chrono/tzdb.h (+1-1)
- (modified) libcxx/include/__functional/boyer_moore_searcher.h (+1-1)
- (modified) libcxx/include/__fwd/vector.h (+3)
- (modified) libcxx/include/__random/discrete_distribution.h (+1-1)
- (modified) libcxx/include/__random/piecewise_constant_distribution.h (+1-1)
- (modified) libcxx/include/__random/piecewise_linear_distribution.h (+3-1)
- (modified) libcxx/include/__random/seed_seq.h (+1-1)
- (added) libcxx/include/__vector/comparison.h (+72)
- (added) libcxx/include/__vector/erase.h (+50)
- (added) libcxx/include/__vector/formatter.h (+49)
- (added) libcxx/include/__vector/pmr.h (+33)
- (added) libcxx/include/__vector/swap.h (+29)
- (added) libcxx/include/__vector/vector.h (+1528)
- (added) libcxx/include/__vector/vector_bool.h (+1118)
- (modified) libcxx/include/chrono (+1)
- (modified) libcxx/include/functional (+1-1)
- (modified) libcxx/include/module.modulemap (+30)
- (modified) libcxx/include/vector (+30-2686)
- (modified) libcxx/test/libcxx/containers/sequences/vector.bool/abi.compile.pass.cpp (+1)
- (modified) libcxx/test/libcxx/containers/sequences/vector/abi.compile.pass.cpp (+1)
- (modified) libcxx/test/libcxx/memory/swap_allocator.pass.cpp (+1-2)
- (modified) libcxx/test/libcxx/transitive_includes/cxx03.csv (+2)
- (modified) libcxx/test/libcxx/transitive_includes/cxx11.csv (+2)
- (modified) libcxx/test/libcxx/transitive_includes/cxx14.csv (+2)
- (modified) libcxx/test/libcxx/transitive_includes/cxx17.csv (+2)
- (modified) libcxx/test/libcxx/transitive_includes/cxx20.csv (+2)
- (modified) libcxx/test/libcxx/transitive_includes/cxx23.csv (+4-3)
- (modified) libcxx/test/libcxx/transitive_includes/cxx26.csv (+4-3)
- (modified) libcxx/test/std/atomics/atomics.ref/assign.pass.cpp (+1)
- (modified) libcxx/test/std/time/time.zone/time.zone.leap/members/date.pass.cpp (+1)
- (modified) libcxx/test/std/time/time.zone/time.zone.leap/members/value.pass.cpp (+1)
- (modified) libcxx/test/std/time/time.zone/time.zone.link/time.zone.link.members/name.pass.cpp (+1)
- (modified) libcxx/test/std/time/time.zone/time.zone.link/time.zone.link.members/target.pass.cpp (+1)
- (modified) libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/name.pass.cpp (+1)
- (modified) libcxx/test/std/time/time.zone/time.zone.zonedtraits/const_time_zone_default_zone.pass.cpp (+2-1)
- (modified) libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp (+2-1)
``````````diff
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 32579272858a8..e1079e8d4a178 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -871,6 +871,13 @@ set(files
__utility/to_underlying.h
__utility/unreachable.h
__variant/monostate.h
+ __vector/comparison.h
+ __vector/erase.h
+ __vector/formatter.h
+ __vector/pmr.h
+ __vector/swap.h
+ __vector/vector.h
+ __vector/vector_bool.h
__verbose_abort
algorithm
any
diff --git a/libcxx/include/__chrono/tzdb.h b/libcxx/include/__chrono/tzdb.h
index f731f8c318be0..fa7d815e1a285 100644
--- a/libcxx/include/__chrono/tzdb.h
+++ b/libcxx/include/__chrono/tzdb.h
@@ -21,8 +21,8 @@
# include <__chrono/time_zone.h>
# include <__chrono/time_zone_link.h>
# include <__config>
+# include <__vector/vector.h>
# include <string>
-# include <vector>
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__functional/boyer_moore_searcher.h b/libcxx/include/__functional/boyer_moore_searcher.h
index 648b60c505219..917a59a0dce16 100644
--- a/libcxx/include/__functional/boyer_moore_searcher.h
+++ b/libcxx/include/__functional/boyer_moore_searcher.h
@@ -22,9 +22,9 @@
#include <__memory/shared_ptr.h>
#include <__type_traits/make_unsigned.h>
#include <__utility/pair.h>
+#include <__vector/vector.h>
#include <array>
#include <unordered_map>
-#include <vector>
#if _LIBCPP_STD_VER >= 17
diff --git a/libcxx/include/__fwd/vector.h b/libcxx/include/__fwd/vector.h
index c9cc96137449f..6980e40ec9187 100644
--- a/libcxx/include/__fwd/vector.h
+++ b/libcxx/include/__fwd/vector.h
@@ -21,6 +21,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Alloc = allocator<_Tp> >
class _LIBCPP_TEMPLATE_VIS vector;
+template <class _Allocator>
+class vector<bool, _Allocator>;
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FWD_VECTOR_H
diff --git a/libcxx/include/__random/discrete_distribution.h b/libcxx/include/__random/discrete_distribution.h
index bb72dd6cb5074..e5a814fbfa0e4 100644
--- a/libcxx/include/__random/discrete_distribution.h
+++ b/libcxx/include/__random/discrete_distribution.h
@@ -13,10 +13,10 @@
#include <__config>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
+#include <__vector/vector.h>
#include <cstddef>
#include <iosfwd>
#include <numeric>
-#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__random/piecewise_constant_distribution.h b/libcxx/include/__random/piecewise_constant_distribution.h
index e19380f97c35e..a9ac5fb676036 100644
--- a/libcxx/include/__random/piecewise_constant_distribution.h
+++ b/libcxx/include/__random/piecewise_constant_distribution.h
@@ -13,9 +13,9 @@
#include <__config>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
+#include <__vector/vector.h>
#include <iosfwd>
#include <numeric>
-#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__random/piecewise_linear_distribution.h b/libcxx/include/__random/piecewise_linear_distribution.h
index 43769dc825e65..24aa6cce91cf2 100644
--- a/libcxx/include/__random/piecewise_linear_distribution.h
+++ b/libcxx/include/__random/piecewise_linear_distribution.h
@@ -13,9 +13,11 @@
#include <__config>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
+#include <__vector/comparison.h>
+#include <__vector/vector.h>
#include <cmath>
+#include <initializer_list>
#include <iosfwd>
-#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__random/seed_seq.h b/libcxx/include/__random/seed_seq.h
index 5cf84aeb8a72b..a629f0a41b790 100644
--- a/libcxx/include/__random/seed_seq.h
+++ b/libcxx/include/__random/seed_seq.h
@@ -15,9 +15,9 @@
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__type_traits/is_unsigned.h>
+#include <__vector/vector.h>
#include <cstdint>
#include <initializer_list>
-#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__vector/comparison.h b/libcxx/include/__vector/comparison.h
new file mode 100644
index 0000000000000..083785ead9d4e
--- /dev/null
+++ b/libcxx/include/__vector/comparison.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___VECTOR_COMPARISON_H
+#define _LIBCPP___VECTOR_COMPARISON_H
+
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/lexicographical_compare_three_way.h>
+#include <__compare/synth_three_way.h>
+#include <__config>
+#include <__fwd/vector.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI bool
+operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
+ const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();
+ return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+#if _LIBCPP_STD_VER <= 17
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
+ return !(__x == __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_HIDE_FROM_ABI bool operator<(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
+ return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_HIDE_FROM_ABI bool operator>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
+ return __y < __x;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
+ return !(__x < __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
+ return !(__y < __x);
+}
+
+#else // _LIBCPP_STD_VER <= 17
+
+template <class _Tp, class _Allocator>
+_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
+operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
+ return std::lexicographical_compare_three_way(
+ __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
+}
+
+#endif // _LIBCPP_STD_VER <= 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___VECTOR_COMPARISON_H
diff --git a/libcxx/include/__vector/erase.h b/libcxx/include/__vector/erase.h
new file mode 100644
index 0000000000000..d7379fc1d04e1
--- /dev/null
+++ b/libcxx/include/__vector/erase.h
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___VECTOR_ERASE_H
+#define _LIBCPP___VECTOR_ERASE_H
+
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__config>
+#include <__fwd/vector.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 20
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Allocator, class _Up>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
+erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
+ auto __old_size = __c.size();
+ __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());
+ return __old_size - __c.size();
+}
+
+template <class _Tp, class _Allocator, class _Predicate>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
+erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
+ auto __old_size = __c.size();
+ __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());
+ return __old_size - __c.size();
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___VECTOR_ERASE_H
diff --git a/libcxx/include/__vector/formatter.h b/libcxx/include/__vector/formatter.h
new file mode 100644
index 0000000000000..b17674a5945b1
--- /dev/null
+++ b/libcxx/include/__vector/formatter.h
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___VECTOR_FORMATTER_H
+#define _LIBCPP___VECTOR_FORMATTER_H
+
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/formatter.h>
+#include <__format/formatter_bool.h>
+#include <__fwd/vector.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _CharT>
+// Since is-vector-bool-reference is only used once it's inlined here.
+ requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>
+struct _LIBCPP_TEMPLATE_VIS formatter<_Tp, _CharT> {
+private:
+ formatter<bool, _CharT> __underlying_;
+
+public:
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return __underlying_.parse(__ctx);
+ }
+
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const {
+ return __underlying_.format(__ref, __ctx);
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___VECTOR_FORMATTER_H
diff --git a/libcxx/include/__vector/pmr.h b/libcxx/include/__vector/pmr.h
new file mode 100644
index 0000000000000..8ef603c739a17
--- /dev/null
+++ b/libcxx/include/__vector/pmr.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___VECTOR_PMR_H
+#define _LIBCPP___VECTOR_PMR_H
+
+#include <__config>
+#include <__fwd/vector.h>
+#include <__memory_resource/polymorphic_allocator.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace pmr {
+template <class _ValueT>
+using vector _LIBCPP_AVAILABILITY_PMR = std::vector<_ValueT, polymorphic_allocator<_ValueT>>;
+} // namespace pmr
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif
+
+#endif // _LIBCPP___VECTOR_PMR_H
diff --git a/libcxx/include/__vector/swap.h b/libcxx/include/__vector/swap.h
new file mode 100644
index 0000000000000..7fe27a91419b3
--- /dev/null
+++ b/libcxx/include/__vector/swap.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___VECTOR_SWAP_H
+#define _LIBCPP___VECTOR_SWAP_H
+
+#include <__config>
+#include <__fwd/vector.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
+swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
+ __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___VECTOR_SWAP_H
diff --git a/libcxx/include/__vector/vector.h b/libcxx/include/__vector/vector.h
new file mode 100644
index 0000000000000..f493bba705923
--- /dev/null
+++ b/libcxx/include/__vector/vector.h
@@ -0,0 +1,1528 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___VECTOR_VECTOR_H
+#define _LIBCPP___VECTOR_VECTOR_H
+
+#include <__algorithm/fill_n.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/min.h>
+#include <__algorithm/rotate.h>
+#include <__config>
+#include <__debug_utils/sanitizers.h>
+#include <__format/enable_insertable.h>
+#include <__fwd/vector.h>
+#include <__iterator/distance.h>
+#include <__iterator/next.h>
+#include <__iterator/reverse_iterator.h>
+#include <__iterator/wrap_iter.h>
+#include <__memory/addressof.h>
+#include <__memory/allocator.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/temp_value.h>
+#include <__memory/uninitialized_algorithms.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/container_compatible_range.h>
+#include <__ranges/from_range.h>
+#include <__split_buffer>
+#include <__type_traits/is_allocator.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_trivially_relocatable.h>
+#include <__type_traits/noexcept_move_assign_container.h>
+#include <__type_traits/type_identity.h>
+#include <__utility/exception_guard.h>
+#include <__utility/is_pointer_in_range.h>
+#include <__vector/comparison.h>
+#include <__vector/swap.h>
+#include <initializer_list>
+#include <limits>
+#include <stdexcept>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Allocator /* = allocator<_Tp> */>
+class _LIBCPP_TEMPLATE_VIS vector {
+private:
+ typedef allocator<_Tp> __default_allocator_type;
+
+public:
+ typedef vector __self;
+ typedef _Tp value_type;
+ typedef _Allocator allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename __alloc_traits::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
+#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
+ // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
+ // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
+ // considered contiguous.
+ typedef __bounded_iter<__wrap_iter<pointer>> iterator;
+ typedef __bounded_iter<__wrap_iter<const_pointer>> const_iterator;
+#else
+ typedef __wrap_iter<pointer> iterator;
+ typedef __wrap_iter<const_pointer> const_iterator;
+#endif
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ // A vector containers the following members which may be trivially relocatable:
+ // - pointer: may be trivially relocatable, so it's checked
+ // - allocator_type: may be trivially relocatable, so it's checked
+ // vector doesn't contain any self-references, so it's trivially relocatable if its members are.
+ using __trivially_relocatable = __conditional_t<
+ __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
+ vector,
+ void>;
+
+ static_assert(__check_valid_allocator<allocator_type>::value, "");
+ static_assert(is_same<typename allocator_type::value_type, value_type>::value,
+ "Allocator::value_type must be same type as value_type");
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+ noexcept
+#endif
+ : __end_cap_(nullptr, __a) {
+ }
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) {
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ if (__n > 0) {
+ __vallocate(__n);
+ __construct_at_end(__n);
+ }
+ __guard.__complete();
+ }
+
+#if _LIBCPP_STD_VER >= 14
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a)
+ : __end_cap_(nullptr, __a) {
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ if (__n > 0) {
+ __vallocate(__n);
+ __construct_at_end(__n);
+ }
+ __guard.__complete();
+ }
+#endif
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) {
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ if (__n > 0) {
+ __vallocate(__n);
+ __construct_at_end(__n, __x);
+ }
+ __guard.__complete();
+ }
+
+ template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
+ vector(size_type __n, const value_type& __x, const allocator_type& __a)
+ : __end_cap_(nullptr, __a) {
+ if (__n > 0) {
+ __vallocate(__n);
+ __construct_at_end(__n, __x);
+ }
+ }
+
+ template <class _InputIterator,
+ __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);
+ template <class _InputIterator,
+ __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
+ vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
+
+ template <
+ class _ForwardIterator,
+ __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);
+
+ template <
+ class _ForwardIterator,
+ __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
+ vector(_ForwardIte...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/99705
More information about the libcxx-commits
mailing list