Skip to content

Commit ee22e25

Browse files
authored
[libc++] Remove <array> include from <span> (#83742)
This reduces the include time of `<span>` from 122ms to 78ms.
1 parent 4028267 commit ee22e25

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

libcxx/include/__fwd/array.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ template <size_t _Ip, class _Tp, size_t _Size>
3535
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT;
3636
#endif
3737

38+
template <class>
39+
struct __is_std_array : false_type {};
40+
41+
template <class _Tp, size_t _Size>
42+
struct __is_std_array<array<_Tp, _Size> > : true_type {};
43+
3844
_LIBCPP_END_NAMESPACE_STD
3945

4046
#endif // _LIBCPP___FWD_ARRAY_H

libcxx/include/span

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,29 @@ template<class R>
130130

131131
#include <__assert>
132132
#include <__config>
133+
#include <__fwd/array.h>
133134
#include <__fwd/span.h>
134135
#include <__iterator/bounded_iter.h>
135136
#include <__iterator/concepts.h>
136137
#include <__iterator/iterator_traits.h>
138+
#include <__iterator/reverse_iterator.h>
137139
#include <__iterator/wrap_iter.h>
138140
#include <__memory/pointer_traits.h>
139141
#include <__ranges/concepts.h>
140142
#include <__ranges/data.h>
141143
#include <__ranges/enable_borrowed_range.h>
142144
#include <__ranges/enable_view.h>
143145
#include <__ranges/size.h>
146+
#include <__type_traits/is_array.h>
147+
#include <__type_traits/is_const.h>
144148
#include <__type_traits/is_convertible.h>
149+
#include <__type_traits/remove_cv.h>
145150
#include <__type_traits/remove_cvref.h>
146151
#include <__type_traits/remove_reference.h>
147152
#include <__type_traits/type_identity.h>
148153
#include <__utility/forward.h>
149-
#include <array> // for array
150-
#include <cstddef> // for byte
154+
#include <cstddef> // for byte
155+
#include <initializer_list>
151156
#include <stdexcept>
152157
#include <version>
153158

@@ -171,12 +176,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
171176

172177
#if _LIBCPP_STD_VER >= 20
173178

174-
template <class _Tp>
175-
struct __is_std_array : false_type {};
176-
177-
template <class _Tp, size_t _Sz>
178-
struct __is_std_array<array<_Tp, _Sz>> : true_type {};
179-
180179
template <class _Tp>
181180
struct __is_std_span : false_type {};
182181

@@ -586,6 +585,7 @@ _LIBCPP_END_NAMESPACE_STD
586585
_LIBCPP_POP_MACROS
587586

588587
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
588+
# include <array>
589589
# include <concepts>
590590
# include <functional>
591591
# include <iterator>

libcxx/test/libcxx/transitive_includes/cxx23.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ shared_mutex string
509509
shared_mutex version
510510
source_location cstdint
511511
source_location version
512-
span array
513512
span cstddef
514513
span initializer_list
515514
span limits

libcxx/test/libcxx/transitive_includes/cxx26.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ shared_mutex string
509509
shared_mutex version
510510
source_location cstdint
511511
source_location version
512-
span array
513512
span cstddef
514513
span initializer_list
515514
span limits

libcxx/test/std/ranges/range.utility/range.subrange/operator.pair_like.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// requires pair-like-convertible-from<PairLike, const I&, const S&>
1414
// constexpr operator PairLike() const;
1515

16+
#include <array>
1617
#include <cassert>
1718
#include <concepts>
1819
#include <ranges>

0 commit comments

Comments
 (0)