Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions libcxx/include/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ struct __tuple_impl;

struct __forward_args {};
struct __value_init {};
struct __from_tuple {};

template <size_t... _Indx, class... _Tp>
struct _LIBCPP_DECLSPEC_EMPTY_BASES
Expand All @@ -538,7 +539,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES
: __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, _Args>(), __alloc, std::forward<_Args>(__args))... {}

template <class _Tuple>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(_Tuple&& __t) noexcept(
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(__from_tuple, _Tuple&& __t) noexcept(
(__all<is_nothrow_constructible<
_Tp,
typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Expand All @@ -547,7 +548,8 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES
std::get<_Indx>(__t)))... {}

template <class _Alloc, class _Tuple>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
__tuple_impl(allocator_arg_t, const _Alloc& __a, __from_tuple, _Tuple&& __t)
: __tuple_leaf<_Indx, _Tp>(
__uses_alloc_ctor<_Tp,
_Alloc,
Expand Down Expand Up @@ -673,13 +675,13 @@ public:
template <class...> class _And = _And,
__enable_if_t< _And<is_copy_constructible<_Tp>...>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
: __base_(allocator_arg_t(), __alloc, __t) {}
: __base_(allocator_arg_t(), __alloc, __from_tuple(), __t) {}

template <class _Alloc,
template <class...> class _And = _And,
__enable_if_t< _And<is_move_constructible<_Tp>...>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
: __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
: __base_(allocator_arg_t(), __alloc, __from_tuple(), std::move(__t)) {}

// tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)

Expand Down Expand Up @@ -712,56 +714,56 @@ public:
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
tuple(const tuple<_Up...>& __t) noexcept(_And<is_nothrow_constructible<_Tp, const _Up&>...>::value)
: __base_(__t) {}
: __base_(__from_tuple(), __t) {}

template <class... _Up,
class _Alloc,
__enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
: __base_(allocator_arg_t(), __a, __t) {}
: __base_(allocator_arg_t(), __a, __from_tuple(), __t) {}

# if _LIBCPP_STD_VER >= 23
// tuple(tuple<U...>&) constructors (including allocator_arg_t variants)

template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(tuple<_Up...>& __t)
: __base_(__t) {}
: __base_(__from_tuple(), __t) {}

template <class _Alloc, class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value)
tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t)
: __base_(allocator_arg_t(), __alloc, __t) {}
: __base_(allocator_arg_t(), __alloc, __from_tuple(), __t) {}
# endif // _LIBCPP_STD_VER >= 23

// tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
tuple(tuple<_Up...>&& __t) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
: __base_(std::move(__t)) {}
: __base_(__from_tuple(), std::move(__t)) {}

template <class _Alloc,
class... _Up,
__enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
: __base_(allocator_arg_t(), __a, std::move(__t)) {}
: __base_(allocator_arg_t(), __a, __from_tuple(), std::move(__t)) {}

# if _LIBCPP_STD_VER >= 23
// tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)

template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
tuple(const tuple<_Up...>&& __t)
: __base_(std::move(__t)) {}
: __base_(__from_tuple(), std::move(__t)) {}

template <class _Alloc,
class... _Up,
enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
: __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
: __base_(allocator_arg_t(), __alloc, __from_tuple(), std::move(__t)) {}
# endif // _LIBCPP_STD_VER >= 23

// tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
Expand Down Expand Up @@ -796,7 +798,7 @@ public:
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
tuple(const pair<_Up1, _Up2>& __p) noexcept(_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)
: __base_(__p) {}
: __base_(__from_tuple(), __p) {}

template <class _Alloc,
class _Up1,
Expand All @@ -806,23 +808,23 @@ public:
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
: __base_(allocator_arg_t(), __a, __p) {}
: __base_(allocator_arg_t(), __a, __from_tuple(), __p) {}

# if _LIBCPP_STD_VER >= 23
// tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)

template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
tuple(pair<_U1, _U2>& __p)
: __base_(__p) {}
: __base_(__from_tuple(), __p) {}

template <class _Alloc,
class _U1,
class _U2,
enable_if_t< _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p)
: __base_(allocator_arg_t(), __alloc, __p) {}
: __base_(allocator_arg_t(), __alloc, __from_tuple(), __p) {}
# endif

// tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
Expand All @@ -834,7 +836,7 @@ public:
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
tuple(pair<_Up1, _Up2>&& __p) noexcept(_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)
: __base_(std::move(__p)) {}
: __base_(__from_tuple(), std::move(__p)) {}

template <class _Alloc,
class _Up1,
Expand All @@ -844,23 +846,23 @@ public:
_LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
: __base_(allocator_arg_t(), __a, std::move(__p)) {}
: __base_(allocator_arg_t(), __a, __from_tuple(), std::move(__p)) {}

# if _LIBCPP_STD_VER >= 23
// tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)

template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
tuple(const pair<_U1, _U2>&& __p)
: __base_(std::move(__p)) {}
: __base_(__from_tuple(), std::move(__p)) {}

template <class _Alloc,
class _U1,
class _U2,
enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)
: __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
: __base_(allocator_arg_t(), __alloc, __from_tuple(), std::move(__p)) {}
# endif // _LIBCPP_STD_VER >= 23

// [tuple.assign]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// Ensure that tuple's move constructor properly SFINAES.
// This is a regression test for https://github.com/llvm/llvm-project/pull/151654#issuecomment-3205410955

// UNSUPPORTED: c++03, c++11, c++14

#include <tuple>
#include <variant>
#include <type_traits>

struct S {
S(const S&) = delete;
S& operator=(const S&) = delete;
S(S&&) = default;
S& operator=(S&&) = default;
};

using T = std::tuple<const std::variant<S>>;

void func() { (void)std::is_trivially_move_constructible<T>::value; }
Loading