[libcxx-commits] [libcxx] 2d52c6b - [libc++] Granularize __tuple
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 5 07:36:34 PDT 2022
Author: Nikolas Klauser
Date: 2022-09-05T16:36:24+02:00
New Revision: 2d52c6bfae801b016dd3627b8c0e7c4a99405549
URL: https://github.com/llvm/llvm-project/commit/2d52c6bfae801b016dd3627b8c0e7c4a99405549
DIFF: https://github.com/llvm/llvm-project/commit/2d52c6bfae801b016dd3627b8c0e7c4a99405549.diff
LOG: [libc++] Granularize __tuple
Reviewed By: ldionne, #libc
Spies: libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D133081
Added:
libcxx/include/__fwd/array.h
libcxx/include/__fwd/get.h
libcxx/include/__fwd/tuple.h
libcxx/include/__tuple/apply_cv.h
libcxx/include/__tuple/make_tuple_types.h
libcxx/include/__tuple/sfinae_helpers.h
libcxx/include/__tuple/tuple_element.h
libcxx/include/__tuple/tuple_indices.h
libcxx/include/__tuple/tuple_like.h
libcxx/include/__tuple/tuple_size.h
libcxx/include/__tuple/tuple_types.h
Modified:
libcxx/include/CMakeLists.txt
libcxx/include/__functional/hash.h
libcxx/include/__ranges/subrange.h
libcxx/include/__utility/integer_sequence.h
libcxx/include/__utility/pair.h
libcxx/include/array
libcxx/include/experimental/memory_resource
libcxx/include/module.modulemap.in
libcxx/include/optional
libcxx/include/ranges
libcxx/include/tuple
libcxx/include/utility
libcxx/include/variant
libcxx/test/libcxx/private_headers.verify.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp
Removed:
libcxx/include/__tuple
################################################################################
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index e72b42cd5a050..cce8db80a6c6c 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -332,10 +332,13 @@ set(files
__functional/unary_negate.h
__functional/unwrap_ref.h
__functional/weak_result_type.h
+ __fwd/array.h
+ __fwd/get.h
__fwd/hash.h
__fwd/pair.h
__fwd/span.h
__fwd/string_view.h
+ __fwd/tuple.h
__hash_table
__ios/fpos.h
__iterator/access.h
@@ -513,7 +516,14 @@ set(files
__thread/timed_backoff_policy.h
__threading_support
__tree
- __tuple
+ __tuple/apply_cv.h
+ __tuple/make_tuple_types.h
+ __tuple/sfinae_helpers.h
+ __tuple/tuple_element.h
+ __tuple/tuple_indices.h
+ __tuple/tuple_like.h
+ __tuple/tuple_size.h
+ __tuple/tuple_types.h
__type_traits/add_const.h
__type_traits/add_cv.h
__type_traits/add_lvalue_reference.h
diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index 138323f5713ca..c1212778868c4 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -12,7 +12,7 @@
#include <__config>
#include <__functional/unary_function.h>
#include <__fwd/hash.h>
-#include <__tuple>
+#include <__tuple/sfinae_helpers.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/pair.h>
diff --git a/libcxx/include/__fwd/array.h b/libcxx/include/__fwd/array.h
new file mode 100644
index 0000000000000..9a79effb617d2
--- /dev/null
+++ b/libcxx/include/__fwd/array.h
@@ -0,0 +1,26 @@
+//===---------------------------------------------------------------------===//
+//
+// 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___FWD_ARRAY_H
+#define _LIBCPP___FWD_ARRAY_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, size_t _Size>
+struct _LIBCPP_TEMPLATE_VIS array;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_ARRAY_H
diff --git a/libcxx/include/__fwd/get.h b/libcxx/include/__fwd/get.h
new file mode 100644
index 0000000000000..81624038980e6
--- /dev/null
+++ b/libcxx/include/__fwd/get.h
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___FWD_GET_H
+#define _LIBCPP___FWD_GET_H
+
+#include <__config>
+#include <__fwd/array.h>
+#include <__fwd/pair.h>
+#include <__fwd/tuple.h>
+#include <__tuple/tuple_element.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(tuple<_Tp...>&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(const tuple<_Tp...>&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(tuple<_Tp...>&&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(const tuple<_Tp...>&&) _NOEXCEPT;
+
+#endif //_LIBCPP_CXX03_LANG
+
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+typename tuple_element<_Ip, pair<_T1, _T2> >::type&
+get(pair<_T1, _T2>&) _NOEXCEPT;
+
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
+get(const pair<_T1, _T2>&) _NOEXCEPT;
+
+#ifndef _LIBCPP_CXX03_LANG
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(pair<_T1, _T2>&&) _NOEXCEPT;
+
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(const pair<_T1, _T2>&&) _NOEXCEPT;
+#endif
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_Tp&
+get(array<_Tp, _Size>&) _NOEXCEPT;
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const _Tp&
+get(const array<_Tp, _Size>&) _NOEXCEPT;
+
+#ifndef _LIBCPP_CXX03_LANG
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_Tp&&
+get(array<_Tp, _Size>&&) _NOEXCEPT;
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const _Tp&&
+get(const array<_Tp, _Size>&&) _NOEXCEPT;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_GET_H
diff --git a/libcxx/include/__fwd/tuple.h b/libcxx/include/__fwd/tuple.h
new file mode 100644
index 0000000000000..16b3fabbb9951
--- /dev/null
+++ b/libcxx/include/__fwd/tuple.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___FWD_TUPLE_H
+#define _LIBCPP___FWD_TUPLE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class...>
+class _LIBCPP_TEMPLATE_VIS tuple;
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_TUPLE_H
diff --git a/libcxx/include/__ranges/subrange.h b/libcxx/include/__ranges/subrange.h
index 74de775496969..f8bfddd0f8cd8 100644
--- a/libcxx/include/__ranges/subrange.h
+++ b/libcxx/include/__ranges/subrange.h
@@ -16,6 +16,7 @@
#include <__concepts/derived_from.h>
#include <__concepts/
diff erent_from.h>
#include <__config>
+#include <__fwd/get.h>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
@@ -26,7 +27,8 @@
#include <__ranges/enable_borrowed_range.h>
#include <__ranges/size.h>
#include <__ranges/view_interface.h>
-#include <__tuple>
+#include <__tuple/tuple_element.h>
+#include <__tuple/tuple_size.h>
#include <__utility/move.h>
#include <type_traits>
diff --git a/libcxx/include/__tuple b/libcxx/include/__tuple
deleted file mode 100644
index abd8e13b134b2..0000000000000
--- a/libcxx/include/__tuple
+++ /dev/null
@@ -1,551 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// 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___TUPLE
-#define _LIBCPP___TUPLE
-
-#include <__config>
-#include <__fwd/pair.h>
-#include <cstddef>
-#include <type_traits>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size;
-
-#if !defined(_LIBCPP_CXX03_LANG)
-template <class _Tp, class...>
-using __enable_if_tuple_size_imp = _Tp;
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
- const _Tp,
- __enable_if_t<!is_volatile<_Tp>::value>,
- integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
- : public integral_constant<size_t, tuple_size<_Tp>::value> {};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
- volatile _Tp,
- __enable_if_t<!is_const<_Tp>::value>,
- integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
- : public integral_constant<size_t, tuple_size<_Tp>::value> {};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
- const volatile _Tp,
- integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
- : public integral_constant<size_t, tuple_size<_Tp>::value> {};
-
-#else
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
-#endif
-
-template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
-
-template <size_t _Ip, class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
-{
- typedef _LIBCPP_NODEBUG typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
-};
-
-template <size_t _Ip, class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
-{
- typedef _LIBCPP_NODEBUG typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
-};
-
-template <size_t _Ip, class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
-{
- typedef _LIBCPP_NODEBUG typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
-};
-
-template <class _Tp> struct __tuple_like : false_type {};
-
-template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
-template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
-template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
-
-// tuple specializations
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template <size_t...> struct __tuple_indices {};
-
-template <class _IdxType, _IdxType... _Values>
-struct __integer_sequence {
- template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
- using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
-
- template <size_t _Sp>
- using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
-};
-
-#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
-namespace __detail {
-
-template<typename _Tp, size_t ..._Extra> struct __repeat;
-template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
- typedef _LIBCPP_NODEBUG __integer_sequence<_Tp,
- _Np...,
- sizeof...(_Np) + _Np...,
- 2 * sizeof...(_Np) + _Np...,
- 3 * sizeof...(_Np) + _Np...,
- 4 * sizeof...(_Np) + _Np...,
- 5 * sizeof...(_Np) + _Np...,
- 6 * sizeof...(_Np) + _Np...,
- 7 * sizeof...(_Np) + _Np...,
- _Extra...> type;
-};
-
-template<size_t _Np> struct __parity;
-template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
-
-template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
-template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
-template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
-template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
-template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
-template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
-template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
-template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
-
-template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
-template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
-template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
-template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
-template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
-template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
-template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
-template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
-
-} // namespace detail
-
-#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
-
-#if __has_builtin(__make_integer_seq)
-template <size_t _Ep, size_t _Sp>
-using __make_indices_imp =
- typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
- __to_tuple_indices<_Sp>;
-#else
-template <size_t _Ep, size_t _Sp>
-using __make_indices_imp =
- typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
-
-#endif
-
-template <size_t _Ep, size_t _Sp = 0>
-struct __make_tuple_indices
-{
- static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
- typedef __make_indices_imp<_Ep, _Sp> type;
-};
-
-
-template <class ..._Tp> class _LIBCPP_TEMPLATE_VIS tuple;
-
-template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
-
-template <class ..._Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
- : public integral_constant<size_t, sizeof...(_Tp)>
-{
-};
-
-template <size_t _Ip, class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-typename tuple_element<_Ip, tuple<_Tp...> >::type&
-get(tuple<_Tp...>&) _NOEXCEPT;
-
-template <size_t _Ip, class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-const typename tuple_element<_Ip, tuple<_Tp...> >::type&
-get(const tuple<_Tp...>&) _NOEXCEPT;
-
-template <size_t _Ip, class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-typename tuple_element<_Ip, tuple<_Tp...> >::type&&
-get(tuple<_Tp...>&&) _NOEXCEPT;
-
-template <size_t _Ip, class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
-get(const tuple<_Tp...>&&) _NOEXCEPT;
-
-#endif // !defined(_LIBCPP_CXX03_LANG)
-
-// pair specializations
-
-template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
-
-template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-typename tuple_element<_Ip, pair<_T1, _T2> >::type&
-get(pair<_T1, _T2>&) _NOEXCEPT;
-
-template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
-get(const pair<_T1, _T2>&) _NOEXCEPT;
-
-#ifndef _LIBCPP_CXX03_LANG
-template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
-get(pair<_T1, _T2>&&) _NOEXCEPT;
-
-template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
-get(const pair<_T1, _T2>&&) _NOEXCEPT;
-#endif
-
-// array specializations
-
-template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
-
-template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
-
-template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-_Tp&
-get(array<_Tp, _Size>&) _NOEXCEPT;
-
-template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-const _Tp&
-get(const array<_Tp, _Size>&) _NOEXCEPT;
-
-#ifndef _LIBCPP_CXX03_LANG
-template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-_Tp&&
-get(array<_Tp, _Size>&&) _NOEXCEPT;
-
-template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-const _Tp&&
-get(const array<_Tp, _Size>&&) _NOEXCEPT;
-#endif
-
-#ifndef _LIBCPP_CXX03_LANG
-
-// __tuple_types
-
-template <class ..._Tp> struct __tuple_types {};
-
-#if !__has_builtin(__type_pack_element)
-
-namespace __indexer_detail {
-
-template <size_t _Idx, class _Tp>
-struct __indexed { using type _LIBCPP_NODEBUG = _Tp; };
-
-template <class _Types, class _Indexes> struct __indexer;
-
-template <class ..._Types, size_t ..._Idx>
-struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
- : __indexed<_Idx, _Types>...
-{};
-
-template <size_t _Idx, class _Tp>
-__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
-
-} // namespace __indexer_detail
-
-template <size_t _Idx, class ..._Types>
-using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
- __indexer_detail::__at_index<_Idx>(
- __indexer_detail::__indexer<
- __tuple_types<_Types...>,
- typename __make_tuple_indices<sizeof...(_Types)>::type
- >{})
- )::type;
-#endif
-
-template <size_t _Ip, class ..._Types>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> >
-{
- static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
- typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
-};
-
-
-template <class ..._Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
- : public integral_constant<size_t, sizeof...(_Tp)>
-{
-};
-
-template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
-
-template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
-struct __apply_cv_mf;
-template <>
-struct __apply_cv_mf<false, false, false> {
- template <class _Tp> using __apply = _Tp;
-};
-template <>
-struct __apply_cv_mf<false, true, false> {
- template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp;
-};
-template <>
-struct __apply_cv_mf<false, false, true> {
- template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp;
-};
-template <>
-struct __apply_cv_mf<false, true, true> {
- template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp;
-};
-template <>
-struct __apply_cv_mf<true, false, false> {
- template <class _Tp> using __apply _LIBCPP_NODEBUG = _Tp&;
-};
-template <>
-struct __apply_cv_mf<true, true, false> {
- template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp&;
-};
-template <>
-struct __apply_cv_mf<true, false, true> {
- template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp&;
-};
-template <>
-struct __apply_cv_mf<true, true, true> {
- template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp&;
-};
-template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
-using __apply_cv_t _LIBCPP_NODEBUG = __apply_cv_mf<
- is_lvalue_reference<_Tp>::value,
- is_const<_RawTp>::value,
- is_volatile<_RawTp>::value>;
-
-// __make_tuple_types
-
-// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
-// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
-// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
-// lvalue_reference type, then __tuple_types<_Types&...> is the result.
-
-template <class _TupleTypes, class _TupleIndices>
-struct __make_tuple_types_flat;
-
-template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
-struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
- // Specialization for pair, tuple, and __tuple_types
- template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
- using __apply_quals _LIBCPP_NODEBUG = __tuple_types<
- typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
- >;
-};
-
-template <class _Vt, size_t _Np, size_t ..._Idx>
-struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
- template <size_t>
- using __value_type = _Vt;
- template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
- using __apply_quals = __tuple_types<
- typename _ApplyFn::template __apply<__value_type<_Idx>>...
- >;
-};
-
-template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
- size_t _Sp = 0,
- bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
-struct __make_tuple_types
-{
- static_assert(_Sp <= _Ep, "__make_tuple_types input error");
- using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
- using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
- using type = typename _Maker::template __apply_quals<_Tp>;
-};
-
-template <class ..._Types, size_t _Ep>
-struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
- typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
-};
-
-template <class ..._Types, size_t _Ep>
-struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
- typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
-};
-
-template <bool ..._Preds>
-struct __all_dummy;
-
-template <bool ..._Pred>
-struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>> {};
-
-struct __tuple_sfinae_base {
- template <template <class, class...> class _Trait,
- class ..._LArgs, class ..._RArgs>
- static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
- -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
- template <template <class...> class>
- static auto __do_test(...) -> false_type;
-
- template <class _FromArgs, class _ToArgs>
- using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
- template <class _FromArgs, class _ToArgs>
- using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
- template <class _FromArgs, class _ToArgs>
- using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
-};
-
-// __tuple_convertible
-
-template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
- bool = __tuple_like<_Up>::value>
-struct __tuple_convertible
- : public false_type {};
-
-template <class _Tp, class _Up>
-struct __tuple_convertible<_Tp, _Up, true, true>
- : public __tuple_sfinae_base::__convertible<
- typename __make_tuple_types<_Tp>::type
- , typename __make_tuple_types<_Up>::type
- >
-{};
-
-// __tuple_constructible
-
-template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
- bool = __tuple_like<_Up>::value>
-struct __tuple_constructible
- : public false_type {};
-
-template <class _Tp, class _Up>
-struct __tuple_constructible<_Tp, _Up, true, true>
- : public __tuple_sfinae_base::__constructible<
- typename __make_tuple_types<_Tp>::type
- , typename __make_tuple_types<_Up>::type
- >
-{};
-
-// __tuple_assignable
-
-template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
- bool = __tuple_like<_Up>::value>
-struct __tuple_assignable
- : public false_type {};
-
-template <class _Tp, class _Up>
-struct __tuple_assignable<_Tp, _Up, true, true>
- : public __tuple_sfinae_base::__assignable<
- typename __make_tuple_types<_Tp>::type
- , typename __make_tuple_types<_Up&>::type
- >
-{};
-
-
-template <size_t _Ip, class ..._Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
-{
- typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <size_t _Ip, class ..._Tp>
-using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element <_Ip, _Tp...>::type;
-#endif
-
-template <bool _IsTuple, class _SizeTrait, size_t _Expected>
-struct __tuple_like_with_size_imp : false_type {};
-
-template <class _SizeTrait, size_t _Expected>
-struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
- : integral_constant<bool, _SizeTrait::value == _Expected> {};
-
-template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __uncvref_t<_Tuple> >
-using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
- __tuple_like<_RawTuple>::value,
- tuple_size<_RawTuple>, _ExpectedSize
- >;
-
-struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
-
- static constexpr bool __enable_explicit_default() { return false; }
- static constexpr bool __enable_implicit_default() { return false; }
- template <class ...>
- static constexpr bool __enable_explicit() { return false; }
- template <class ...>
- static constexpr bool __enable_implicit() { return false; }
- template <class ...>
- static constexpr bool __enable_assign() { return false; }
-};
-#endif // !defined(_LIBCPP_CXX03_LANG)
-
-#if _LIBCPP_STD_VER > 14
-
-template <bool _CanCopy, bool _CanMove>
-struct __sfinae_ctor_base {};
-template <>
-struct __sfinae_ctor_base<false, false> {
- __sfinae_ctor_base() = default;
- __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
- __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
- __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
- __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
-};
-template <>
-struct __sfinae_ctor_base<true, false> {
- __sfinae_ctor_base() = default;
- __sfinae_ctor_base(__sfinae_ctor_base const&) = default;
- __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
- __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
- __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
-};
-template <>
-struct __sfinae_ctor_base<false, true> {
- __sfinae_ctor_base() = default;
- __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
- __sfinae_ctor_base(__sfinae_ctor_base &&) = default;
- __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
- __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
-};
-
-template <bool _CanCopy, bool _CanMove>
-struct __sfinae_assign_base {};
-template <>
-struct __sfinae_assign_base<false, false> {
- __sfinae_assign_base() = default;
- __sfinae_assign_base(__sfinae_assign_base const&) = default;
- __sfinae_assign_base(__sfinae_assign_base &&) = default;
- __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
- __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
-};
-template <>
-struct __sfinae_assign_base<true, false> {
- __sfinae_assign_base() = default;
- __sfinae_assign_base(__sfinae_assign_base const&) = default;
- __sfinae_assign_base(__sfinae_assign_base &&) = default;
- __sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
- __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
-};
-template <>
-struct __sfinae_assign_base<false, true> {
- __sfinae_assign_base() = default;
- __sfinae_assign_base(__sfinae_assign_base const&) = default;
- __sfinae_assign_base(__sfinae_assign_base &&) = default;
- __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
- __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
-};
-#endif // _LIBCPP_STD_VER > 14
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TUPLE
diff --git a/libcxx/include/__tuple/apply_cv.h b/libcxx/include/__tuple/apply_cv.h
new file mode 100644
index 0000000000000..91969009f6bbb
--- /dev/null
+++ b/libcxx/include/__tuple/apply_cv.h
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___TUPLE_APPLY_CV_H
+#define _LIBCPP___TUPLE_APPLY_CV_H
+
+#include <__config>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_volatile.h>
+#include <__type_traits/remove_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
+struct __apply_cv_mf;
+template <>
+struct __apply_cv_mf<false, false, false> {
+ template <class _Tp> using __apply = _Tp;
+};
+template <>
+struct __apply_cv_mf<false, true, false> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp;
+};
+template <>
+struct __apply_cv_mf<false, false, true> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp;
+};
+template <>
+struct __apply_cv_mf<false, true, true> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp;
+};
+template <>
+struct __apply_cv_mf<true, false, false> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = _Tp&;
+};
+template <>
+struct __apply_cv_mf<true, true, false> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp&;
+};
+template <>
+struct __apply_cv_mf<true, false, true> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp&;
+};
+template <>
+struct __apply_cv_mf<true, true, true> {
+ template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp&;
+};
+template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
+using __apply_cv_t _LIBCPP_NODEBUG = __apply_cv_mf<
+ is_lvalue_reference<_Tp>::value,
+ is_const<_RawTp>::value,
+ is_volatile<_RawTp>::value>;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___TUPLE_APPLY_CV_H
diff --git a/libcxx/include/__tuple/make_tuple_types.h b/libcxx/include/__tuple/make_tuple_types.h
new file mode 100644
index 0000000000000..0827b2d504d92
--- /dev/null
+++ b/libcxx/include/__tuple/make_tuple_types.h
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___TUPLE_MAKE_TUPLE_TYPES_H
+#define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
+
+#include <__config>
+#include <__fwd/array.h>
+#include <__fwd/tuple.h>
+#include <__tuple/apply_cv.h>
+#include <__tuple/tuple_element.h>
+#include <__tuple/tuple_indices.h>
+#include <__tuple/tuple_size.h>
+#include <__tuple/tuple_types.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_reference.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
+// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
+// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
+// lvalue_reference type, then __tuple_types<_Types&...> is the result.
+
+template <class _TupleTypes, class _TupleIndices>
+struct __make_tuple_types_flat;
+
+template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
+struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
+ // Specialization for pair, tuple, and __tuple_types
+ template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
+ using __apply_quals _LIBCPP_NODEBUG = __tuple_types<
+ typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
+ >;
+};
+
+template <class _Vt, size_t _Np, size_t ..._Idx>
+struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
+ template <size_t>
+ using __value_type = _Vt;
+ template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
+ using __apply_quals = __tuple_types<
+ typename _ApplyFn::template __apply<__value_type<_Idx>>...
+ >;
+};
+
+template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
+ size_t _Sp = 0,
+ bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
+struct __make_tuple_types
+{
+ static_assert(_Sp <= _Ep, "__make_tuple_types input error");
+ using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
+ using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
+ using type = typename _Maker::template __apply_quals<_Tp>;
+};
+
+template <class ..._Types, size_t _Ep>
+struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
+ typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
+};
+
+template <class ..._Types, size_t _Ep>
+struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
+ typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
diff --git a/libcxx/include/__tuple/sfinae_helpers.h b/libcxx/include/__tuple/sfinae_helpers.h
new file mode 100644
index 0000000000000..ce2fe7c3caf3c
--- /dev/null
+++ b/libcxx/include/__tuple/sfinae_helpers.h
@@ -0,0 +1,196 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___TUPLE_SFINAE_HELPERS_H
+#define _LIBCPP___TUPLE_SFINAE_HELPERS_H
+
+#include <__config>
+#include <__fwd/tuple.h>
+#include <__tuple/make_tuple_types.h>
+#include <__tuple/tuple_element.h>
+#include <__tuple/tuple_like.h>
+#include <__tuple/tuple_size.h>
+#include <__tuple/tuple_types.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/remove_reference.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <bool ..._Preds>
+struct __all_dummy;
+
+template <bool ..._Pred>
+struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>> {};
+
+struct __tuple_sfinae_base {
+ template <template <class, class...> class _Trait,
+ class ..._LArgs, class ..._RArgs>
+ static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
+ -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
+ template <template <class...> class>
+ static auto __do_test(...) -> false_type;
+
+ template <class _FromArgs, class _ToArgs>
+ using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
+ template <class _FromArgs, class _ToArgs>
+ using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
+ template <class _FromArgs, class _ToArgs>
+ using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
+};
+
+// __tuple_convertible
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+ bool = __tuple_like<_Up>::value>
+struct __tuple_convertible
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_convertible<_Tp, _Up, true, true>
+ : public __tuple_sfinae_base::__convertible<
+ typename __make_tuple_types<_Tp>::type
+ , typename __make_tuple_types<_Up>::type
+ >
+{};
+
+// __tuple_constructible
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+ bool = __tuple_like<_Up>::value>
+struct __tuple_constructible
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_constructible<_Tp, _Up, true, true>
+ : public __tuple_sfinae_base::__constructible<
+ typename __make_tuple_types<_Tp>::type
+ , typename __make_tuple_types<_Up>::type
+ >
+{};
+
+// __tuple_assignable
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+ bool = __tuple_like<_Up>::value>
+struct __tuple_assignable
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_assignable<_Tp, _Up, true, true>
+ : public __tuple_sfinae_base::__assignable<
+ typename __make_tuple_types<_Tp>::type
+ , typename __make_tuple_types<_Up&>::type
+ >
+{};
+
+
+template <size_t _Ip, class ..._Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
+{
+ typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
+};
+
+template <bool _IsTuple, class _SizeTrait, size_t _Expected>
+struct __tuple_like_with_size_imp : false_type {};
+
+template <class _SizeTrait, size_t _Expected>
+struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
+ : integral_constant<bool, _SizeTrait::value == _Expected> {};
+
+template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __uncvref_t<_Tuple> >
+using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
+ __tuple_like<_RawTuple>::value,
+ tuple_size<_RawTuple>, _ExpectedSize
+ >;
+
+struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
+
+ static constexpr bool __enable_explicit_default() { return false; }
+ static constexpr bool __enable_implicit_default() { return false; }
+ template <class ...>
+ static constexpr bool __enable_explicit() { return false; }
+ template <class ...>
+ static constexpr bool __enable_implicit() { return false; }
+ template <class ...>
+ static constexpr bool __enable_assign() { return false; }
+};
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
+#if _LIBCPP_STD_VER > 14
+
+template <bool _CanCopy, bool _CanMove>
+struct __sfinae_ctor_base {};
+template <>
+struct __sfinae_ctor_base<false, false> {
+ __sfinae_ctor_base() = default;
+ __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
+ __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
+};
+template <>
+struct __sfinae_ctor_base<true, false> {
+ __sfinae_ctor_base() = default;
+ __sfinae_ctor_base(__sfinae_ctor_base const&) = default;
+ __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
+};
+template <>
+struct __sfinae_ctor_base<false, true> {
+ __sfinae_ctor_base() = default;
+ __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
+ __sfinae_ctor_base(__sfinae_ctor_base &&) = default;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
+ __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
+};
+
+template <bool _CanCopy, bool _CanMove>
+struct __sfinae_assign_base {};
+template <>
+struct __sfinae_assign_base<false, false> {
+ __sfinae_assign_base() = default;
+ __sfinae_assign_base(__sfinae_assign_base const&) = default;
+ __sfinae_assign_base(__sfinae_assign_base &&) = default;
+ __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
+ __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
+};
+template <>
+struct __sfinae_assign_base<true, false> {
+ __sfinae_assign_base() = default;
+ __sfinae_assign_base(__sfinae_assign_base const&) = default;
+ __sfinae_assign_base(__sfinae_assign_base &&) = default;
+ __sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
+ __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
+};
+template <>
+struct __sfinae_assign_base<false, true> {
+ __sfinae_assign_base() = default;
+ __sfinae_assign_base(__sfinae_assign_base const&) = default;
+ __sfinae_assign_base(__sfinae_assign_base &&) = default;
+ __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
+ __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
+};
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_SFINAE_HELPERS_H
diff --git a/libcxx/include/__tuple/tuple_element.h b/libcxx/include/__tuple/tuple_element.h
new file mode 100644
index 0000000000000..d30b2c148dbfe
--- /dev/null
+++ b/libcxx/include/__tuple/tuple_element.h
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___TUPLE_TUPLE_ELEMENT_H
+#define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
+
+#include <__config>
+#include <__tuple/tuple_indices.h>
+#include <__tuple/tuple_types.h>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_cv.h>
+#include <__type_traits/add_volatile.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
+{
+ typedef _LIBCPP_NODEBUG typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
+};
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
+{
+ typedef _LIBCPP_NODEBUG typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
+};
+
+template <size_t _Ip, class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
+{
+ typedef _LIBCPP_NODEBUG typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+#if !__has_builtin(__type_pack_element)
+
+namespace __indexer_detail {
+
+template <size_t _Idx, class _Tp>
+struct __indexed { using type _LIBCPP_NODEBUG = _Tp; };
+
+template <class _Types, class _Indexes> struct __indexer;
+
+template <class ..._Types, size_t ..._Idx>
+struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
+ : __indexed<_Idx, _Types>...
+{};
+
+template <size_t _Idx, class _Tp>
+__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
+
+} // namespace __indexer_detail
+
+template <size_t _Idx, class ..._Types>
+using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
+ __indexer_detail::__at_index<_Idx>(
+ __indexer_detail::__indexer<
+ __tuple_types<_Types...>,
+ typename __make_tuple_indices<sizeof...(_Types)>::type
+ >{})
+ )::type;
+#endif
+
+template <size_t _Ip, class ..._Types>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> >
+{
+ static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
+ typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Ip, class ..._Tp>
+using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element <_Ip, _Tp...>::type;
+#endif
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_ELEMENT_H
diff --git a/libcxx/include/__tuple/tuple_indices.h b/libcxx/include/__tuple/tuple_indices.h
new file mode 100644
index 0000000000000..18666d5948c9b
--- /dev/null
+++ b/libcxx/include/__tuple/tuple_indices.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___TUPLE_MAKE_TUPLE_INDICES_H
+#define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
+
+#include <__config>
+#include <__utility/integer_sequence.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <size_t...> struct __tuple_indices {};
+
+template <size_t _Ep, size_t _Sp = 0>
+struct __make_tuple_indices
+{
+ static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
+ typedef __make_indices_imp<_Ep, _Sp> type;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
diff --git a/libcxx/include/__tuple/tuple_like.h b/libcxx/include/__tuple/tuple_like.h
new file mode 100644
index 0000000000000..3b596916a65e6
--- /dev/null
+++ b/libcxx/include/__tuple/tuple_like.h
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___TUPLE_TUPLE_LIKE_H
+#define _LIBCPP___TUPLE_TUPLE_LIKE_H
+
+#include <__config>
+#include <__fwd/array.h>
+#include <__fwd/pair.h>
+#include <__fwd/tuple.h>
+#include <__tuple/tuple_types.h>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct __tuple_like : false_type {};
+
+template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
+template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
+template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
+#endif
+
+template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
+
+template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
+
+template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_LIKE_H
diff --git a/libcxx/include/__tuple/tuple_size.h b/libcxx/include/__tuple/tuple_size.h
new file mode 100644
index 0000000000000..26f9d9725d316
--- /dev/null
+++ b/libcxx/include/__tuple/tuple_size.h
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___TUPLE_TUPLE_SIZE_H
+#define _LIBCPP___TUPLE_TUPLE_SIZE_H
+
+#include <__config>
+#include <__fwd/tuple.h>
+#include <__tuple/tuple_types.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_volatile.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size;
+
+#if !defined(_LIBCPP_CXX03_LANG)
+template <class _Tp, class...>
+using __enable_if_tuple_size_imp = _Tp;
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
+ const _Tp,
+ __enable_if_t<!is_volatile<_Tp>::value>,
+ integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+ : public integral_constant<size_t, tuple_size<_Tp>::value> {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
+ volatile _Tp,
+ __enable_if_t<!is_const<_Tp>::value>,
+ integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+ : public integral_constant<size_t, tuple_size<_Tp>::value> {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
+ const volatile _Tp,
+ integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+ : public integral_constant<size_t, tuple_size<_Tp>::value> {};
+
+#else
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class ..._Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
+ : public integral_constant<size_t, sizeof...(_Tp)>
+{
+};
+
+template <class ..._Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
+ : public integral_constant<size_t, sizeof...(_Tp)>
+{
+};
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_SIZE_H
diff --git a/libcxx/include/__tuple/tuple_types.h b/libcxx/include/__tuple/tuple_types.h
new file mode 100644
index 0000000000000..c5be81cce8015
--- /dev/null
+++ b/libcxx/include/__tuple/tuple_types.h
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___TUPLE_TUPLE_TYPES_H
+#define _LIBCPP___TUPLE_TUPLE_TYPES_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class ..._Tp> struct __tuple_types {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_TYPES_H
diff --git a/libcxx/include/__utility/integer_sequence.h b/libcxx/include/__utility/integer_sequence.h
index 633f1333e2479..87c76e9d92514 100644
--- a/libcxx/include/__utility/integer_sequence.h
+++ b/libcxx/include/__utility/integer_sequence.h
@@ -18,6 +18,72 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+template <size_t...> struct __tuple_indices;
+
+template <class _IdxType, _IdxType... _Values>
+struct __integer_sequence {
+ template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
+ using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
+
+ template <size_t _Sp>
+ using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
+};
+
+#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
+
+namespace __detail {
+
+template<typename _Tp, size_t ..._Extra> struct __repeat;
+template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
+ typedef _LIBCPP_NODEBUG __integer_sequence<_Tp,
+ _Np...,
+ sizeof...(_Np) + _Np...,
+ 2 * sizeof...(_Np) + _Np...,
+ 3 * sizeof...(_Np) + _Np...,
+ 4 * sizeof...(_Np) + _Np...,
+ 5 * sizeof...(_Np) + _Np...,
+ 6 * sizeof...(_Np) + _Np...,
+ 7 * sizeof...(_Np) + _Np...,
+ _Extra...> type;
+};
+
+template<size_t _Np> struct __parity;
+template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
+
+template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
+template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
+template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
+template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
+template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
+template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
+template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
+template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
+
+template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
+template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
+template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+
+} // namespace detail
+
+#endif
+
+#if __has_builtin(__make_integer_seq)
+template <size_t _Ep, size_t _Sp>
+using __make_indices_imp =
+ typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
+ __to_tuple_indices<_Sp>;
+#else
+template <size_t _Ep, size_t _Sp>
+using __make_indices_imp =
+ typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
+
+#endif
+
#if _LIBCPP_STD_VER > 11
template<class _Tp, _Tp... _Ip>
diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h
index 6669b9a62748b..2f6c8f5017773 100644
--- a/libcxx/include/__utility/pair.h
+++ b/libcxx/include/__utility/pair.h
@@ -13,7 +13,12 @@
#include <__compare/synth_three_way.h>
#include <__config>
#include <__functional/unwrap_ref.h>
-#include <__tuple>
+#include <__fwd/get.h>
+#include <__fwd/tuple.h>
+#include <__tuple/sfinae_helpers.h>
+#include <__tuple/tuple_element.h>
+#include <__tuple/tuple_indices.h>
+#include <__tuple/tuple_size.h>
#include <__type_traits/is_implicitly_default_constructible.h>
#include <__utility/forward.h>
#include <__utility/move.h>
diff --git a/libcxx/include/array b/libcxx/include/array
index 4b91569514ead..a145b487476f9 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -115,7 +115,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__iterator/reverse_iterator.h>
-#include <__tuple>
+#include <__tuple/sfinae_helpers.h>
#include <__utility/integer_sequence.h>
#include <__utility/move.h>
#include <__utility/unreachable.h>
@@ -136,6 +136,10 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
#include <compare>
#include <initializer_list>
+// [tuple.helper]
+#include <__tuple/tuple_element.h>
+#include <__tuple/tuple_size.h>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/experimental/memory_resource b/libcxx/include/experimental/memory_resource
index f6f01dcd15cb3..146e520c57c59 100644
--- a/libcxx/include/experimental/memory_resource
+++ b/libcxx/include/experimental/memory_resource
@@ -66,7 +66,6 @@ namespace pmr {
#include <__assert> // all public C++ headers provide the assertion handler
#include <__memory/allocator_traits.h>
-#include <__tuple>
#include <__utility/move.h>
#include <cstddef>
#include <cstdlib>
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index e9f8cdc82f558..4898daed6bfbf 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -446,6 +446,8 @@ module std [system] {
header "array"
export initializer_list
export *
+
+ module array_fwd { private header "__fwd/array.h" }
}
module atomic {
header "atomic"
@@ -1100,6 +1102,17 @@ module std [system] {
module tuple {
header "tuple"
export *
+
+ module apply_cv { private header "__tuple/apply_cv.h" }
+ module get_fwd { private header "__fwd/get.h" }
+ module make_tuple_types { private header "__tuple/make_tuple_types.h" }
+ module sfinae_helpers { private header "__tuple/sfinae_helpers.h" }
+ module tuple_element { private header "__tuple/tuple_element.h" }
+ module tuple_fwd { private header "__fwd/tuple.h" }
+ module tuple_indices { private header "__tuple/tuple_indices.h" }
+ module tuple_like { private header "__tuple/tuple_like.h" }
+ module tuple_size { private header "__tuple/tuple_size.h" }
+ module tuple_types { private header "__tuple/tuple_types.h" }
}
module type_traits {
header "type_traits"
@@ -1325,7 +1338,6 @@ module std [system] {
}
module __threading_support { header "__threading_support" export * }
module __tree { header "__tree" export * }
- module __tuple { private header "__tuple" export * }
module __undef_macros { header "__undef_macros" export * }
module __verbose_abort { header "__verbose_abort" export * }
diff --git a/libcxx/include/optional b/libcxx/include/optional
index 38412afcc7b4e..0d79d30c78f95 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -166,7 +166,7 @@ template<class T>
#include <__functional/invoke.h>
#include <__functional/unary_function.h>
#include <__memory/construct_at.h>
-#include <__tuple>
+#include <__tuple/sfinae_helpers.h>
#include <__utility/forward.h>
#include <__utility/in_place.h>
#include <__utility/move.h>
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index 0129f295cfa1a..b2e14cdccc33d 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -302,15 +302,20 @@ namespace std {
#include <__ranges/view_interface.h>
#include <__ranges/views.h>
#include <__ranges/zip_view.h>
-#include <__tuple> // TODO: <ranges> has to export std::tuple_size. Replace this, once <tuple> is granularized.
#include <type_traits>
#include <version>
// standard-mandated includes
+
+// [ranges.syn]
#include <compare>
#include <initializer_list>
#include <iterator>
+// [tuple.helper]
+#include <__tuple/tuple_element.h>
+#include <__tuple/tuple_size.h>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index 7bf2f91d06b46..0241a7c54e218 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -206,9 +206,9 @@ template <class... Types>
#include <__compare/synth_three_way.h>
#include <__config>
#include <__functional/unwrap_ref.h>
+#include <__fwd/array.h>
#include <__memory/allocator_arg_t.h>
#include <__memory/uses_allocator.h>
-#include <__tuple>
#include <__type_traits/maybe_const.h>
#include <__utility/forward.h>
#include <__utility/integer_sequence.h>
diff --git a/libcxx/include/utility b/libcxx/include/utility
index 41bcaf3d19465..b14ee43b73be0 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -226,7 +226,6 @@ template <class T>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__tuple>
#include <__utility/as_const.h>
#include <__utility/auto_cast.h>
#include <__utility/cmp.h>
@@ -249,9 +248,15 @@ template <class T>
#include <version>
// standard-mandated includes
+
+// [utility.syn]
#include <compare>
#include <initializer_list>
+// [tuple.helper]
+#include <__tuple/tuple_element.h>
+#include <__tuple/tuple_size.h>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/variant b/libcxx/include/variant
index f1d36e21ce788..32a1795924c6e 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -213,7 +213,6 @@ namespace std {
#include <__functional/hash.h>
#include <__functional/operations.h>
#include <__functional/unary_function.h>
-#include <__tuple>
#include <__type_traits/dependent_type.h>
#include <__utility/forward.h>
#include <__utility/in_place.h>
diff --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp
index c822992e38c0a..0fc45a68c4f4f 100644
--- a/libcxx/test/libcxx/private_headers.verify.cpp
+++ b/libcxx/test/libcxx/private_headers.verify.cpp
@@ -364,10 +364,13 @@ END-SCRIPT
#include <__functional/unary_negate.h> // expected-error@*:* {{use of private header from outside its module: '__functional/unary_negate.h'}}
#include <__functional/unwrap_ref.h> // expected-error@*:* {{use of private header from outside its module: '__functional/unwrap_ref.h'}}
#include <__functional/weak_result_type.h> // expected-error@*:* {{use of private header from outside its module: '__functional/weak_result_type.h'}}
+#include <__fwd/array.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/array.h'}}
+#include <__fwd/get.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/get.h'}}
#include <__fwd/hash.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/hash.h'}}
#include <__fwd/pair.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/pair.h'}}
#include <__fwd/span.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/span.h'}}
#include <__fwd/string_view.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/string_view.h'}}
+#include <__fwd/tuple.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/tuple.h'}}
#include <__ios/fpos.h> // expected-error@*:* {{use of private header from outside its module: '__ios/fpos.h'}}
#include <__iterator/access.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/access.h'}}
#include <__iterator/advance.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/advance.h'}}
@@ -525,7 +528,14 @@ END-SCRIPT
#include <__string/extern_template_lists.h> // expected-error@*:* {{use of private header from outside its module: '__string/extern_template_lists.h'}}
#include <__thread/poll_with_backoff.h> // expected-error@*:* {{use of private header from outside its module: '__thread/poll_with_backoff.h'}}
#include <__thread/timed_backoff_policy.h> // expected-error@*:* {{use of private header from outside its module: '__thread/timed_backoff_policy.h'}}
-#include <__tuple> // expected-error@*:* {{use of private header from outside its module: '__tuple'}}
+#include <__tuple/apply_cv.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/apply_cv.h'}}
+#include <__tuple/make_tuple_types.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/make_tuple_types.h'}}
+#include <__tuple/sfinae_helpers.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/sfinae_helpers.h'}}
+#include <__tuple/tuple_element.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_element.h'}}
+#include <__tuple/tuple_indices.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_indices.h'}}
+#include <__tuple/tuple_like.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_like.h'}}
+#include <__tuple/tuple_size.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_size.h'}}
+#include <__tuple/tuple_types.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_types.h'}}
#include <__type_traits/add_const.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_const.h'}}
#include <__type_traits/add_cv.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_cv.h'}}
#include <__type_traits/add_lvalue_reference.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_lvalue_reference.h'}}
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp
index 2c297749f3b0a..21b69683b680a 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp
@@ -27,8 +27,7 @@ int main(int, char**)
using E1 = typename std::tuple_element<1, T &>::type; // expected-error{{undefined template}}
using E2 = typename std::tuple_element<3, T>::type;
using E3 = typename std::tuple_element<4, T const>::type;
- // expected-error-re at __tuple:* 2 {{{{(static_assert|static assertion)}} failed}}
-
+ // expected-error-re@*:* 2 {{{{(static_assert|static assertion)}} failed}}
return 0;
}
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp
index 8024816dd4133..cde87e1208773 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp
@@ -44,19 +44,19 @@ int main(int, char**)
// Test that tuple_size<const T> is not incomplete when tuple_size<T>::value
// is well-formed but not a constant expression.
{
- // expected-error at __tuple:* 1 {{is not a constant expression}}
+ // expected-error@*:* 1 {{is not a constant expression}}
(void)std::tuple_size<const Dummy1>::value; // expected-note {{here}}
}
// Test that tuple_size<const T> is not incomplete when tuple_size<T>::value
// is well-formed but not convertible to size_t.
{
- // expected-error at __tuple:* 1 {{value of type 'void ()' is not implicitly convertible to}}
+ // expected-error@*:* 1 {{value of type 'void ()' is not implicitly convertible to}}
(void)std::tuple_size<const Dummy2>::value; // expected-note {{here}}
}
// Test that tuple_size<const T> generates an error when tuple_size<T> is
// complete but ::value isn't a constant expression convertible to size_t.
{
- // expected-error at __tuple:* 1 {{no member named 'value'}}
+ // expected-error@*:* 1 {{no member named 'value'}}
(void)std::tuple_size<const Dummy3>::value; // expected-note {{here}}
}
More information about the libcxx-commits
mailing list