-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Granularize <vector> #99705
Conversation
philnik777
commented
Jul 19, 2024
•
edited
Loading
edited
old time | new time | |
---|---|---|
functional - c++23 | 416ms | 225ms |
random - c++23 | 513ms | 392ms |
vector - c++17 | 206ms | 100ms |
✅ With the latest revision this PR passed the C/C++ code formatter. |
f3f3777
to
9b8d8a3
Compare
9b8d8a3
to
c4fbf3b
Compare
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) Changes
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:
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]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for this patch?
There were two goals when I originally started the modularisation of libc++ headers:
- eliminate circular dependencies
- separate completely unrelated entities
This was done with the intention of ensuring that including Header A didn't include all of Header B just for Function F, and to improve lookup (<type_traits>
was the home of many things that it wasn't the prescribed home of).
Splitting <vector>
into seven new headers doesn't achieve the first goal, and I'm not convinced it is achieving the second either.
It allows reducing the compilation times for When we introduced formatters, we got many reports of people finding their compilation times and preprocessed file sizes regressed by a huge amount. That was tracked down to the fact that FWIW, I think we could potentially get away with a less granular split. For example, we could only extract the formatters in one header and have everything else in another header, both of which would be included from Edit:
Here, |
Thanks for the context. I would appreciate it if the commit message incorporated this information, as it isn't currently clear why this change is important.
I'd appreciate seeing the results of an A/B experiment before splitting out |
Splitting out |
Gentle ping @philnik777. I think this is worth doing and @cjdb 's concerns seem to have been addressed. Let's rebase this, then I'll have another look at this and I think this is probably going to be good to go (unless someone else has concerns with this). |
867f357
to
520568a
Compare
520568a
to
3921d73
Compare
9052fca
to
5f35f6c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with my non-resolved comments.
93dbed0
to
7198233
Compare
7198233
to
4457145
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with green CI.
4457145
to
92f2747
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/52/builds/3208 Here is the relevant piece of the build log for the reference
|