Skip to content

Commit 4528c44

Browse files
authored
[libc++] Remove <tuple> include from <__format/concepts.h> (#80214)
This also moves `tuple_size_v` into `tuple_size` as a drive-by.
1 parent 4fef8c7 commit 4528c44

File tree

8 files changed

+15
-11
lines changed

8 files changed

+15
-11
lines changed

libcxx/include/__format/concepts.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
#include <__config>
1616
#include <__format/format_parse_context.h>
1717
#include <__fwd/format.h>
18+
#include <__fwd/tuple.h>
19+
#include <__tuple/tuple_size.h>
1820
#include <__type_traits/is_specialization.h>
1921
#include <__type_traits/remove_const.h>
22+
#include <__type_traits/remove_reference.h>
2023
#include <__utility/pair.h>
21-
#include <tuple>
2224

2325
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2426
# pragma GCC system_header

libcxx/include/__tuple/tuple_size.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< volatile _Tp,
4343

4444
template <class _Tp>
4545
struct _LIBCPP_TEMPLATE_VIS
46-
tuple_size<__enable_if_tuple_size_imp< const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
46+
tuple_size<__enable_if_tuple_size_imp<const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
4747
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
4848

4949
#else
@@ -63,6 +63,11 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > : public integral_constan
6363
template <class... _Tp>
6464
struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {};
6565

66+
# if _LIBCPP_STD_VER >= 17
67+
template <class _Tp>
68+
inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
69+
# endif
70+
6671
#endif // _LIBCPP_CXX03_LANG
6772

6873
_LIBCPP_END_NAMESPACE_STD

libcxx/include/chrono

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ constexpr chrono::year operator ""y(unsigned lo
878878
# include <cstring>
879879
# include <forward_list>
880880
# include <string>
881+
# include <tuple>
881882
#endif
882883

883884
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20

libcxx/include/tuple

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_T1, _T2>::pair(
13691369
second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {}
13701370

13711371
# if _LIBCPP_STD_VER >= 17
1372-
template <class _Tp>
1373-
inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1374-
13751372
# define _LIBCPP_NOEXCEPT_RETURN(...) \
13761373
noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
13771374

libcxx/include/vector

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,6 +2990,7 @@ _LIBCPP_POP_MACROS
29902990
# include <concepts>
29912991
# include <cstdlib>
29922992
# include <locale>
2993+
# include <tuple>
29932994
# include <type_traits>
29942995
# include <typeinfo>
29952996
# include <utility>

libcxx/test/libcxx/transitive_includes/cxx23.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ chrono sstream
8585
chrono stdexcept
8686
chrono string
8787
chrono string_view
88-
chrono tuple
8988
chrono vector
9089
chrono version
9190
cinttypes cstdint

libcxx/test/libcxx/transitive_includes/cxx26.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ chrono sstream
8585
chrono stdexcept
8686
chrono string
8787
chrono string_view
88-
chrono tuple
8988
chrono vector
9089
chrono version
9190
cinttypes cstdint

libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.verify.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include <tuple>
1818

1919
void f() {
20-
(void)std::tuple_size_v<std::tuple<> &>; // expected-note {{requested here}}
21-
(void)std::tuple_size_v<int>; // expected-note {{requested here}}
22-
(void)std::tuple_size_v<std::tuple<>*>; // expected-note {{requested here}}
23-
// expected-error@tuple:* 3 {{implicit instantiation of undefined template}}
20+
(void)std::tuple_size_v<std::tuple<>&>; // expected-note {{requested here}}
21+
(void)std::tuple_size_v<int>; // expected-note {{requested here}}
22+
(void)std::tuple_size_v<std::tuple<>*>; // expected-note {{requested here}}
23+
// expected-error@*:* 3 {{implicit instantiation of undefined template}}
2424
}

0 commit comments

Comments
 (0)