[libc++] Remove pair dependency (#85621)

This moves the definition of a `pair` constructor for `<tuple>` to
`<__utility/pair.h>` and uses the forward declaration of `pair` in
`<tuple>` instead of including the definition.
This commit is contained in:
Nikolas Klauser
2024-04-02 19:37:31 +02:00
committed by GitHub
parent 3cf9f2c3a4
commit 239236b8c2
9 changed files with 15 additions and 19 deletions

View File

@@ -36,6 +36,7 @@
#include <__utility/forward.h>
#include <__utility/integer_sequence.h>
#include <__utility/move.h>
#include <__utility/pair.h>
#include <tuple>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@@ -431,7 +431,9 @@ private:
tuple<_Args1...>& __first_args,
tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>,
__tuple_indices<_I2...>);
__tuple_indices<_I2...>)
: first(std::forward<_Args1>(std::get<_I1>(__first_args))...),
second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {}
#endif
};

View File

@@ -1738,7 +1738,10 @@ module std_private_ranges_transform_view [system] {
}
module std_private_ranges_view_interface [system] { header "__ranges/view_interface.h" }
module std_private_ranges_views [system] { header "__ranges/views.h" }
module std_private_ranges_zip_view [system] { header "__ranges/zip_view.h" }
module std_private_ranges_zip_view [system] {
header "__ranges/zip_view.h"
export std_private_utility_pair
}
module std_private_span_span_fwd [system] { header "__fwd/span.h" }

View File

@@ -210,6 +210,7 @@ template <class... Types>
#include <__config>
#include <__functional/invoke.h>
#include <__fwd/array.h>
#include <__fwd/pair.h>
#include <__fwd/tuple.h>
#include <__memory/allocator_arg_t.h>
#include <__memory/uses_allocator.h>
@@ -250,7 +251,6 @@ template <class... Types>
#include <__utility/forward.h>
#include <__utility/integer_sequence.h>
#include <__utility/move.h>
#include <__utility/pair.h>
#include <__utility/piecewise_construct.h>
#include <__utility/swap.h>
#include <cstddef>
@@ -1348,17 +1348,6 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {
template <class... _Tp, class _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};
template <class _T1, class _T2>
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_T1, _T2>::pair(
piecewise_construct_t,
tuple<_Args1...>& __first_args,
tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>,
__tuple_indices<_I2...>)
: first(std::forward<_Args1>(std::get<_I1>(__first_args))...),
second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {}
# if _LIBCPP_STD_VER >= 17
# define _LIBCPP_NOEXCEPT_RETURN(...) \
noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }

View File

@@ -13,7 +13,6 @@
// (enable_borrowed_range<Views> && ...);
#include <ranges>
#include <tuple>
struct Borrowed : std::ranges::view_base {
int* begin() const;

View File

@@ -17,6 +17,7 @@
#include <cassert>
#include <concepts>
#include <ranges>
#include <utility>
#include "test_macros.h"

View File

@@ -16,9 +16,10 @@
// UNSUPPORTED: c++03
#include <tuple>
#include <array>
#include <tuple>
#include <type_traits>
#include <utility>
#include "test_macros.h"

View File

@@ -16,10 +16,10 @@
// UNSUPPORTED: c++03, c++11, c++14
#include <tuple>
#include <array>
#include <type_traits>
#include <cassert>
#include <tuple>
#include <utility>
#include "test_macros.h"

View File

@@ -17,7 +17,7 @@
// UNSUPPORTED: c++03
#include <tuple>
#include <type_traits>
#include <utility>
#include "test_macros.h"