blob: 50d31149ee0999a0e7c7a9117ee53b01884a97dc [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- tuple ------------------------------------===//
3//
Chandler Carruth7642bb12019-01-19 08:50:56 +00004// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnantc51e1022010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_TUPLE
11#define _LIBCPP_TUPLE
12
13/*
14 tuple synopsis
15
16namespace std
17{
18
19template <class... T>
20class tuple {
21public:
Louis Dionnea7a2beb2019-09-26 14:51:10 +000022 explicit(see-below) constexpr tuple();
Louis Dionne1afad1d2019-07-22 20:45:23 +000023 explicit(see-below) tuple(const T&...); // constexpr in C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +000024 template <class... U>
Louis Dionne1afad1d2019-07-22 20:45:23 +000025 explicit(see-below) tuple(U&&...); // constexpr in C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +000026 tuple(const tuple&) = default;
Howard Hinnant89ef1212011-05-27 19:08:18 +000027 tuple(tuple&&) = default;
Howard Hinnantc51e1022010-05-11 19:42:16 +000028 template <class... U>
Louis Dionne1afad1d2019-07-22 20:45:23 +000029 explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +000030 template <class... U>
Louis Dionne1afad1d2019-07-22 20:45:23 +000031 explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +000032 template <class U1, class U2>
Louis Dionne1afad1d2019-07-22 20:45:23 +000033 explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +000034 template <class U1, class U2>
Louis Dionne1afad1d2019-07-22 20:45:23 +000035 explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +000036
37 // allocator-extended constructors
38 template <class Alloc>
39 tuple(allocator_arg_t, const Alloc& a);
40 template <class Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050041 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000042 template <class Alloc, class... U>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050043 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000044 template <class Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050045 tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000046 template <class Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050047 tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000048 template <class Alloc, class... U>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050049 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000050 template <class Alloc, class... U>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050051 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000052 template <class Alloc, class U1, class U2>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050053 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000054 template <class Alloc, class U1, class U2>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050055 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000056
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050057 tuple& operator=(const tuple&); // constexpr in C++20
58 tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000059 template <class... U>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050060 tuple& operator=(const tuple<U...>&); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000061 template <class... U>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050062 tuple& operator=(tuple<U...>&&); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000063 template <class U1, class U2>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050064 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000065 template <class U1, class U2>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050066 tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000067
Louis Dionne6c0d5342018-07-31 11:56:20 -040068 template<class U, size_t N>
69 tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION
70 template<class U, size_t N>
71 tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION
72
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -050073 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +000074};
75
Louis Dionne616da2a2019-08-12 18:30:31 +000076template <class ...T>
77tuple(T...) -> tuple<T...>; // since C++17
78template <class T1, class T2>
79tuple(pair<T1, T2>) -> tuple<T1, T2>; // since C++17
80template <class Alloc, class ...T>
81tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>; // since C++17
82template <class Alloc, class T1, class T2>
83tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++17
84template <class Alloc, class ...T>
85tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17
86
Marshall Clowf1bf62f2018-01-02 17:17:01 +000087inline constexpr unspecified ignore;
Howard Hinnantc51e1022010-05-11 19:42:16 +000088
Marshall Clow2229cee2013-07-22 16:02:19 +000089template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
Marshall Clowded420b2013-10-05 18:46:37 +000090template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
Marshall Clowa8892812014-02-25 16:11:46 +000091template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
Marshall Clow2229cee2013-07-22 16:02:19 +000092template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
Eric Fiselier8e892c52016-07-18 00:35:56 +000093
94// [tuple.apply], calling a function with a tuple of arguments:
95template <class F, class Tuple>
96 constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
97template <class T, class Tuple>
98 constexpr T make_from_tuple(Tuple&& t); // C++17
99
Howard Hinnantc51e1022010-05-11 19:42:16 +0000100// 20.4.1.4, tuple helper classes:
Marshall Clowce62b4d2019-01-11 21:57:12 +0000101template <class T> struct tuple_size; // undefined
102template <class... T> struct tuple_size<tuple<T...>>;
Eric Fiselier8e892c52016-07-18 00:35:56 +0000103template <class T>
Marshall Clowf1bf62f2018-01-02 17:17:01 +0000104 inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
Louis Dionnee684aa62019-04-01 16:39:34 +0000105template <size_t I, class T> struct tuple_element; // undefined
106template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;
Marshall Clow36907512015-11-19 19:45:29 +0000107template <size_t I, class T>
108 using tuple_element_t = typename tuple_element <I, T>::type; // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000109
110// 20.4.1.5, element access:
Marshall Clow36907512015-11-19 19:45:29 +0000111template <size_t I, class... T>
Howard Hinnant89ef1212011-05-27 19:08:18 +0000112 typename tuple_element<I, tuple<T...>>::type&
Marshall Clow0abb1042013-07-17 18:25:36 +0000113 get(tuple<T...>&) noexcept; // constexpr in C++14
Marshall Clow36907512015-11-19 19:45:29 +0000114template <size_t I, class... T>
115 const typename tuple_element<I, tuple<T...>>::type&
Marshall Clow0abb1042013-07-17 18:25:36 +0000116 get(const tuple<T...>&) noexcept; // constexpr in C++14
Marshall Clow36907512015-11-19 19:45:29 +0000117template <size_t I, class... T>
Howard Hinnant89ef1212011-05-27 19:08:18 +0000118 typename tuple_element<I, tuple<T...>>::type&&
Marshall Clow0abb1042013-07-17 18:25:36 +0000119 get(tuple<T...>&&) noexcept; // constexpr in C++14
Eric Fiselier6dea8092015-12-18 00:36:55 +0000120template <size_t I, class... T>
121 const typename tuple_element<I, tuple<T...>>::type&&
122 get(const tuple<T...>&&) noexcept; // constexpr in C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000123
Marshall Clow15b02e02013-07-13 02:54:05 +0000124template <class T1, class... T>
125 constexpr T1& get(tuple<T...>&) noexcept; // C++14
126template <class T1, class... T>
Marshall Clow36907512015-11-19 19:45:29 +0000127 constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
Marshall Clow15b02e02013-07-13 02:54:05 +0000128template <class T1, class... T>
129 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
Eric Fiselier6dea8092015-12-18 00:36:55 +0000130template <class T1, class... T>
131 constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
Marshall Clow15b02e02013-07-13 02:54:05 +0000132
Howard Hinnantc51e1022010-05-11 19:42:16 +0000133// 20.4.1.6, relational operators:
Marshall Clow2229cee2013-07-22 16:02:19 +0000134template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
Kent Ross0861b0d2021-10-08 14:54:28 -0700135template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
136template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
137template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
138template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
139template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
140template<class... T, class... U>
141 constexpr common_comparison_category_t<synth-three-way-result<T, U>...>
142 operator<=>(const tuple<T...>&, const tuple<U...>&); // since C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000143
144template <class... Types, class Alloc>
145 struct uses_allocator<tuple<Types...>, Alloc>;
146
147template <class... Types>
Howard Hinnant89ef1212011-05-27 19:08:18 +0000148 void
149 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000150
Howard Hinnantc51e1022010-05-11 19:42:16 +0000151} // std
152
153*/
154
Kent Ross0861b0d2021-10-08 14:54:28 -0700155#include <__compare/common_comparison_category.h>
156#include <__compare/synth_three_way.h>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000157#include <__config>
Christopher Di Bella599a6c62021-06-09 23:10:17 +0000158#include <__functional/unwrap_ref.h>
Christopher Di Bella55d7a822021-07-01 09:25:35 -0400159#include <__functional_base>
160#include <__memory/allocator_arg_t.h>
161#include <__memory/uses_allocator.h>
162#include <__tuple>
Christopher Di Bella41f26e82021-06-05 02:47:47 +0000163#include <__utility/forward.h>
Kent Ross0861b0d2021-10-08 14:54:28 -0700164#include <__utility/integer_sequence.h>
Christopher Di Bella41f26e82021-06-05 02:47:47 +0000165#include <__utility/move.h>
Arthur O'Dwyer7deec122021-03-24 18:19:12 -0400166#include <compare>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000167#include <cstddef>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000168#include <type_traits>
Howard Hinnant83b1c052011-12-19 17:58:44 +0000169#include <utility>
Marshall Clow0a1e7502018-09-12 19:41:40 +0000170#include <version>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000171
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000172#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000173#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000174#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000175
176_LIBCPP_BEGIN_NAMESPACE_STD
177
Eric Fiselierffe4aba2017-04-19 01:23:39 +0000178#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000179
Marshall Clowf50d66f2014-03-03 06:18:11 +0000180
Howard Hinnantc51e1022010-05-11 19:42:16 +0000181// __tuple_leaf
182
Eric Fiselierf7394302015-06-13 07:08:02 +0000183template <size_t _Ip, class _Hp,
184 bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
Howard Hinnantd0aabf82011-12-11 20:31:33 +0000185 >
Howard Hinnantc51e1022010-05-11 19:42:16 +0000186class __tuple_leaf;
187
188template <size_t _Ip, class _Hp, bool _Ep>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500189inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000190void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
Howard Hinnant89ef1212011-05-27 19:08:18 +0000191 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000192{
193 swap(__x.get(), __y.get());
194}
195
196template <size_t _Ip, class _Hp, bool>
197class __tuple_leaf
198{
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000199 _Hp __value_;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000200
Eric Fiselierca8bba12016-07-20 02:57:39 +0000201 template <class _Tp>
202 static constexpr bool __can_bind_reference() {
Eric Fiselier869187d2018-01-24 22:14:01 +0000203#if __has_keyword(__reference_binds_to_temporary)
204 return !__reference_binds_to_temporary(_Hp, _Tp);
Eric Fiselier81c32cb2018-01-24 23:10:02 +0000205#else
206 return true;
Eric Fiselier869187d2018-01-24 22:14:01 +0000207#endif
Eric Fiselierca8bba12016-07-20 02:57:39 +0000208 }
209
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500210 _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000211 __tuple_leaf& operator=(const __tuple_leaf&);
212public:
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500213 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000214 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
Howard Hinnantc51e1022010-05-11 19:42:16 +0000215 {static_assert(!is_reference<_Hp>::value,
216 "Attempted to default construct a reference element in a tuple");}
217
218 template <class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500219 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000220 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000221 : __value_()
Howard Hinnantc51e1022010-05-11 19:42:16 +0000222 {static_assert(!is_reference<_Hp>::value,
223 "Attempted to default construct a reference element in a tuple");}
224
225 template <class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500226 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000227 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000228 : __value_(allocator_arg_t(), __a)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000229 {static_assert(!is_reference<_Hp>::value,
230 "Attempted to default construct a reference element in a tuple");}
231
232 template <class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500233 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000234 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000235 : __value_(__a)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000236 {static_assert(!is_reference<_Hp>::value,
237 "Attempted to default construct a reference element in a tuple");}
238
Howard Hinnant693fc212010-09-27 17:54:17 +0000239 template <class _Tp,
Louis Dionne9ce598d2021-09-08 09:14:43 -0400240 class = __enable_if_t<
Eric Fiselier3906a132019-06-23 20:28:29 +0000241 _And<
242 _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
243 is_constructible<_Hp, _Tp>
Eric Fiselier42fa85e2014-07-24 18:48:34 +0000244 >::value
Eric Fiselier3906a132019-06-23 20:28:29 +0000245 >
Eric Fiselier42fa85e2014-07-24 18:48:34 +0000246 >
Marshall Clow2229cee2013-07-22 16:02:19 +0000247 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant62751642012-07-06 21:53:48 +0000248 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000249 : __value_(_VSTD::forward<_Tp>(__t))
Eric Fiselier869187d2018-01-24 22:14:01 +0000250 {static_assert(__can_bind_reference<_Tp&&>(),
251 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000252
253 template <class _Tp, class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500254 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000255 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000256 : __value_(_VSTD::forward<_Tp>(__t))
Eric Fiselier869187d2018-01-24 22:14:01 +0000257 {static_assert(__can_bind_reference<_Tp&&>(),
258 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000259
260 template <class _Tp, class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500261 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000262 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000263 : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
Eric Fiselierca8bba12016-07-20 02:57:39 +0000264 {static_assert(!is_reference<_Hp>::value,
265 "Attempted to uses-allocator construct a reference element in a tuple");}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000266
267 template <class _Tp, class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500268 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000269 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000270 : __value_(_VSTD::forward<_Tp>(__t), __a)
Eric Fiselierca8bba12016-07-20 02:57:39 +0000271 {static_assert(!is_reference<_Hp>::value,
272 "Attempted to uses-allocator construct a reference element in a tuple");}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000273
Marshall Clow47fcee52014-04-21 23:48:09 +0000274 __tuple_leaf(const __tuple_leaf& __t) = default;
275 __tuple_leaf(__tuple_leaf&& __t) = default;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000276
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500277 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant89ef1212011-05-27 19:08:18 +0000278 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000279 {
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000280 _VSTD::swap(*this, __t);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000281 return 0;
282 }
283
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
285 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000286};
287
288template <size_t _Ip, class _Hp>
289class __tuple_leaf<_Ip, _Hp, true>
290 : private _Hp
291{
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500292 _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000293 __tuple_leaf& operator=(const __tuple_leaf&);
294public:
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500295 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
Howard Hinnantaabb4202012-07-06 20:50:27 +0000296 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000297
298 template <class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500299 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000300 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
301
302 template <class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500303 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000304 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
305 : _Hp(allocator_arg_t(), __a) {}
306
307 template <class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500308 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000309 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
310 : _Hp(__a) {}
311
Howard Hinnant693fc212010-09-27 17:54:17 +0000312 template <class _Tp,
Louis Dionne9ce598d2021-09-08 09:14:43 -0400313 class = __enable_if_t<
Eric Fiselier3906a132019-06-23 20:28:29 +0000314 _And<
315 _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
316 is_constructible<_Hp, _Tp>
317 >::value
318 >
Eric Fiselier42fa85e2014-07-24 18:48:34 +0000319 >
Marshall Clow2229cee2013-07-22 16:02:19 +0000320 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant62751642012-07-06 21:53:48 +0000321 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000322 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000323
324 template <class _Tp, class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500325 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000326 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000327 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000328
329 template <class _Tp, class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500330 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000331 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000332 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000333
334 template <class _Tp, class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500335 _LIBCPP_INLINE_VISIBILITY constexpr
Howard Hinnantc51e1022010-05-11 19:42:16 +0000336 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000337 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000338
Eric Fiselier42fa85e2014-07-24 18:48:34 +0000339 __tuple_leaf(__tuple_leaf const &) = default;
340 __tuple_leaf(__tuple_leaf &&) = default;
341
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500342 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant89ef1212011-05-27 19:08:18 +0000343 int
344 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000345 {
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000346 _VSTD::swap(*this, __t);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000347 return 0;
348 }
349
Marshall Clow2229cee2013-07-22 16:02:19 +0000350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
351 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000352};
353
Howard Hinnant1c265cd2010-09-23 18:58:28 +0000354template <class ..._Tp>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500355_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant62751642012-07-06 21:53:48 +0000356void __swallow(_Tp&&...) _NOEXCEPT {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000357
Marshall Clowc470eae2014-10-15 10:33:02 +0000358template <class _Tp>
359struct __all_default_constructible;
Howard Hinnant89ef1212011-05-27 19:08:18 +0000360
Marshall Clowc470eae2014-10-15 10:33:02 +0000361template <class ..._Tp>
362struct __all_default_constructible<__tuple_types<_Tp...>>
363 : __all<is_default_constructible<_Tp>::value...>
364{ };
Howard Hinnant89ef1212011-05-27 19:08:18 +0000365
Howard Hinnantc51e1022010-05-11 19:42:16 +0000366// __tuple_impl
367
368template<class _Indx, class ..._Tp> struct __tuple_impl;
369
370template<size_t ..._Indx, class ..._Tp>
Eric Fiseliere3cec5f2017-01-16 21:15:08 +0000371struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000372 : public __tuple_leaf<_Indx, _Tp>...
373{
Howard Hinnant38469632012-07-06 20:39:45 +0000374 _LIBCPP_INLINE_VISIBILITY
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500375 constexpr __tuple_impl()
Howard Hinnantaabb4202012-07-06 20:50:27 +0000376 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant38469632012-07-06 20:39:45 +0000377
Howard Hinnantc51e1022010-05-11 19:42:16 +0000378 template <size_t ..._Uf, class ..._Tf,
379 size_t ..._Ul, class ..._Tl, class ..._Up>
Marshall Clow2229cee2013-07-22 16:02:19 +0000380 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000381 explicit
382 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
383 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
Howard Hinnant62751642012-07-06 21:53:48 +0000384 _Up&&... __u)
385 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
386 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000387 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
Howard Hinnantc51e1022010-05-11 19:42:16 +0000388 __tuple_leaf<_Ul, _Tl>()...
389 {}
390
391 template <class _Alloc, size_t ..._Uf, class ..._Tf,
392 size_t ..._Ul, class ..._Tl, class ..._Up>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500393 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000394 explicit
395 __tuple_impl(allocator_arg_t, const _Alloc& __a,
396 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
397 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
398 _Up&&... __u) :
399 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000400 _VSTD::forward<_Up>(__u))...,
Howard Hinnantc51e1022010-05-11 19:42:16 +0000401 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
402 {}
403
404 template <class _Tuple,
405 class = typename enable_if
406 <
Howard Hinnant6da16b82013-04-14 00:01:13 +0000407 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantc51e1022010-05-11 19:42:16 +0000408 >::type
409 >
Marshall Clow2229cee2013-07-22 16:02:19 +0000410 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant62751642012-07-06 21:53:48 +0000411 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
412 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000413 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
414 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantc51e1022010-05-11 19:42:16 +0000415 {}
416
417 template <class _Alloc, class _Tuple,
418 class = typename enable_if
419 <
Eric Fiselier8e6a5f02016-04-19 01:19:25 +0000420 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantc51e1022010-05-11 19:42:16 +0000421 >::type
422 >
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500423 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000424 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
425 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000426 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000427 _VSTD::forward<typename tuple_element<_Indx,
428 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantc51e1022010-05-11 19:42:16 +0000429 {}
430
Howard Hinnant0d032d12013-11-06 17:45:43 +0000431 __tuple_impl(const __tuple_impl&) = default;
432 __tuple_impl(__tuple_impl&&) = default;
433
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500434 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +0000435 void swap(__tuple_impl& __t)
Howard Hinnant89ef1212011-05-27 19:08:18 +0000436 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000437 {
Louis Dionne6c0d5342018-07-31 11:56:20 -0400438 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000439 }
440};
441
Louis Dionne6c0d5342018-07-31 11:56:20 -0400442template<class _Dest, class _Source, size_t ..._Np>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500443_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Louis Dionne6c0d5342018-07-31 11:56:20 -0400444void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {
445 _VSTD::__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 0)...);
446}
Eric Fiselier264d04a2016-04-15 18:05:59 +0000447
Louis Dionne6c0d5342018-07-31 11:56:20 -0400448template<class _Dest, class _Source, class ..._Up, size_t ..._Np>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500449_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Louis Dionne6c0d5342018-07-31 11:56:20 -0400450void __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {
451 _VSTD::__swallow(((
Louis Dionne3b8af4d2021-02-24 14:53:21 -0500452 _VSTD::get<_Np>(__dest) = _VSTD::forward<_Up>(_VSTD::get<_Np>(__source))
Louis Dionne6c0d5342018-07-31 11:56:20 -0400453 ), void(), 0)...);
454}
Eric Fiselier264d04a2016-04-15 18:05:59 +0000455
Howard Hinnantc51e1022010-05-11 19:42:16 +0000456template <class ..._Tp>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000457class _LIBCPP_TEMPLATE_VIS tuple
Howard Hinnantc51e1022010-05-11 19:42:16 +0000458{
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000459 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000460
Eric Fiselier3e0d4372017-06-01 02:14:21 +0000461 _BaseT __base_;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000462
Marshall Clow0abb1042013-07-17 18:25:36 +0000463 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant28b24882011-12-01 20:21:04 +0000464 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
Marshall Clow0abb1042013-07-17 18:25:36 +0000465 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant28b24882011-12-01 20:21:04 +0000466 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
Marshall Clow0abb1042013-07-17 18:25:36 +0000467 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant28b24882011-12-01 20:21:04 +0000468 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
Eric Fiselier6dea8092015-12-18 00:36:55 +0000469 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
470 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000471public:
Louis Dionne574e2e32021-02-10 16:19:50 -0500472 // [tuple.cnstr]
Howard Hinnantc51e1022010-05-11 19:42:16 +0000473
Louis Dionne574e2e32021-02-10 16:19:50 -0500474 // tuple() constructors (including allocator_arg_t variants)
Louis Dionne9ce598d2021-09-08 09:14:43 -0400475 template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500476 _And<
477 _IsImpDefault<_Tp>... // explicit check
478 >::value
479 , int> = 0>
Louis Dionne58bca852021-04-30 15:52:26 -0400480 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
Louis Dionnea7a2beb2019-09-26 14:51:10 +0000481 tuple()
Louis Dionne574e2e32021-02-10 16:19:50 -0500482 _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
483 { }
Louis Dionnea7a2beb2019-09-26 14:51:10 +0000484
Louis Dionne574e2e32021-02-10 16:19:50 -0500485 template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
Louis Dionne9ce598d2021-09-08 09:14:43 -0400486 template<class...> class _IsDefault = is_default_constructible, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500487 _And<
488 _IsDefault<_Tp>...,
489 _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
490 >::value
491 , int> = 0>
492 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
493 explicit tuple()
494 _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
495 { }
Howard Hinnant38469632012-07-06 20:39:45 +0000496
Louis Dionne9ce598d2021-09-08 09:14:43 -0400497 template <class _Alloc, template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500498 _And<
499 _IsImpDefault<_Tp>... // explicit check
500 >::value
501 , int> = 0>
502 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
503 tuple(allocator_arg_t, _Alloc const& __a)
504 : __base_(allocator_arg_t(), __a,
505 __tuple_indices<>(), __tuple_types<>(),
506 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
507 __tuple_types<_Tp...>()) {}
508
509 template <class _Alloc,
510 template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
Louis Dionne9ce598d2021-09-08 09:14:43 -0400511 template<class...> class _IsDefault = is_default_constructible, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500512 _And<
513 _IsDefault<_Tp>...,
514 _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
515 >::value
516 , int> = 0>
517 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
518 explicit tuple(allocator_arg_t, _Alloc const& __a)
519 : __base_(allocator_arg_t(), __a,
520 __tuple_indices<>(), __tuple_types<>(),
521 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
522 __tuple_types<_Tp...>()) {}
523
524 // tuple(const T&...) constructors (including allocator_arg_t variants)
Louis Dionne9ce598d2021-09-08 09:14:43 -0400525 template <template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500526 _And<
527 _BoolConstant<sizeof...(_Tp) >= 1>,
528 is_copy_constructible<_Tp>...,
529 is_convertible<const _Tp&, _Tp>... // explicit check
530 >::value
531 , int> = 0>
532 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
533 tuple(const _Tp& ... __t)
534 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
535 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
536 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
537 typename __make_tuple_indices<0>::type(),
538 typename __make_tuple_types<tuple, 0>::type(),
539 __t...
540 ) {}
541
Louis Dionne9ce598d2021-09-08 09:14:43 -0400542 template <template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500543 _And<
544 _BoolConstant<sizeof...(_Tp) >= 1>,
545 is_copy_constructible<_Tp>...,
546 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
547 >::value
548 , int> = 0>
549 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
550 explicit tuple(const _Tp& ... __t)
551 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
552 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
553 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
554 typename __make_tuple_indices<0>::type(),
555 typename __make_tuple_types<tuple, 0>::type(),
556 __t...
557 ) {}
558
Louis Dionne9ce598d2021-09-08 09:14:43 -0400559 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500560 _And<
561 _BoolConstant<sizeof...(_Tp) >= 1>,
562 is_copy_constructible<_Tp>...,
563 is_convertible<const _Tp&, _Tp>... // explicit check
564 >::value
565 , int> = 0>
566 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
567 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
568 : __base_(allocator_arg_t(), __a,
569 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
570 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
571 typename __make_tuple_indices<0>::type(),
572 typename __make_tuple_types<tuple, 0>::type(),
573 __t...
574 ) {}
575
Louis Dionne9ce598d2021-09-08 09:14:43 -0400576 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500577 _And<
578 _BoolConstant<sizeof...(_Tp) >= 1>,
579 is_copy_constructible<_Tp>...,
580 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
581 >::value
582 , int> = 0>
583 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
584 explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
585 : __base_(allocator_arg_t(), __a,
586 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
587 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
588 typename __make_tuple_indices<0>::type(),
589 typename __make_tuple_types<tuple, 0>::type(),
590 __t...
591 ) {}
592
593 // tuple(U&& ...) constructors (including allocator_arg_t variants)
594 template <class ..._Up> struct _IsThisTuple : false_type { };
595 template <class _Up> struct _IsThisTuple<_Up> : is_same<__uncvref_t<_Up>, tuple> { };
596
597 template <class ..._Up>
598 struct _EnableUTypesCtor : _And<
599 _BoolConstant<sizeof...(_Tp) >= 1>,
600 _Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors
601 is_constructible<_Tp, _Up>...
602 > { };
603
Louis Dionne9ce598d2021-09-08 09:14:43 -0400604 template <class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500605 _And<
606 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
607 _EnableUTypesCtor<_Up...>,
608 is_convertible<_Up, _Tp>... // explicit check
609 >::value
610 , int> = 0>
611 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
612 tuple(_Up&&... __u)
613 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
614 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
615 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
616 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
617 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
618 _VSTD::forward<_Up>(__u)...) {}
619
Louis Dionne9ce598d2021-09-08 09:14:43 -0400620 template <class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500621 _And<
622 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
623 _EnableUTypesCtor<_Up...>,
624 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
625 >::value
626 , int> = 0>
627 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
628 explicit tuple(_Up&&... __u)
629 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
630 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
631 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
632 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
633 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
634 _VSTD::forward<_Up>(__u)...) {}
635
Louis Dionne9ce598d2021-09-08 09:14:43 -0400636 template <class _Alloc, class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500637 _And<
638 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
639 _EnableUTypesCtor<_Up...>,
640 is_convertible<_Up, _Tp>... // explicit check
641 >::value
642 , int> = 0>
643 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
644 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
645 : __base_(allocator_arg_t(), __a,
646 typename __make_tuple_indices<sizeof...(_Up)>::type(),
647 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
648 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
649 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
650 _VSTD::forward<_Up>(__u)...) {}
651
Louis Dionne9ce598d2021-09-08 09:14:43 -0400652 template <class _Alloc, class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500653 _And<
654 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
655 _EnableUTypesCtor<_Up...>,
656 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
657 >::value
658 , int> = 0>
659 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
660 explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
661 : __base_(allocator_arg_t(), __a,
662 typename __make_tuple_indices<sizeof...(_Up)>::type(),
663 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
664 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
665 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
666 _VSTD::forward<_Up>(__u)...) {}
667
668 // Copy and move constructors (including the allocator_arg_t variants)
669 tuple(const tuple&) = default;
Eric Fiselier737a16d2016-07-25 02:36:42 +0000670 tuple(tuple&&) = default;
671
Louis Dionne9ce598d2021-09-08 09:14:43 -0400672 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500673 _And<is_copy_constructible<_Tp>...>::value
674 , int> = 0>
675 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
676 : __base_(allocator_arg_t(), __alloc, __t)
677 { }
678
Louis Dionne9ce598d2021-09-08 09:14:43 -0400679 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500680 _And<is_move_constructible<_Tp>...>::value
681 , int> = 0>
682 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
683 : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))
684 { }
685
686 // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
687 template <class ..._Up>
688 struct _EnableCopyFromOtherTuple : _And<
Louis Dionnedb7e65d2021-05-03 12:21:13 -0400689 _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >,
690 _Lazy<_Or,
Louis Dionne574e2e32021-02-10 16:19:50 -0500691 _BoolConstant<sizeof...(_Tp) != 1>,
692 // _Tp and _Up are 1-element packs - the pack expansions look
693 // weird to avoid tripping up the type traits in degenerate cases
694 _Lazy<_And,
Louis Dionne574e2e32021-02-10 16:19:50 -0500695 _Not<is_convertible<const tuple<_Up>&, _Tp> >...,
696 _Not<is_constructible<_Tp, const tuple<_Up>&> >...
697 >
698 >,
699 is_constructible<_Tp, const _Up&>...
700 > { };
701
Louis Dionne9ce598d2021-09-08 09:14:43 -0400702 template <class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500703 _And<
704 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
705 _EnableCopyFromOtherTuple<_Up...>,
706 is_convertible<const _Up&, _Tp>... // explicit check
707 >::value
708 , int> = 0>
709 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
710 tuple(const tuple<_Up...>& __t)
711 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
712 : __base_(__t)
713 { }
714
Louis Dionne9ce598d2021-09-08 09:14:43 -0400715 template <class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500716 _And<
717 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
718 _EnableCopyFromOtherTuple<_Up...>,
719 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
720 >::value
721 , int> = 0>
722 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
723 explicit tuple(const tuple<_Up...>& __t)
724 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
725 : __base_(__t)
726 { }
727
Louis Dionne9ce598d2021-09-08 09:14:43 -0400728 template <class ..._Up, class _Alloc, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500729 _And<
730 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
731 _EnableCopyFromOtherTuple<_Up...>,
732 is_convertible<const _Up&, _Tp>... // explicit check
733 >::value
734 , int> = 0>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500735 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne574e2e32021-02-10 16:19:50 -0500736 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
737 : __base_(allocator_arg_t(), __a, __t)
738 { }
Eric Fiselierc170df52016-04-15 03:29:40 +0000739
Louis Dionne9ce598d2021-09-08 09:14:43 -0400740 template <class ..._Up, class _Alloc, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500741 _And<
742 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
743 _EnableCopyFromOtherTuple<_Up...>,
744 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
745 >::value
746 , int> = 0>
747 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
748 explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
749 : __base_(allocator_arg_t(), __a, __t)
750 { }
Louis Dionne668a50c2019-09-27 15:06:52 +0000751
Louis Dionne574e2e32021-02-10 16:19:50 -0500752 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
753 template <class ..._Up>
754 struct _EnableMoveFromOtherTuple : _And<
Louis Dionnedb7e65d2021-05-03 12:21:13 -0400755 _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >,
756 _Lazy<_Or,
Louis Dionne574e2e32021-02-10 16:19:50 -0500757 _BoolConstant<sizeof...(_Tp) != 1>,
758 // _Tp and _Up are 1-element packs - the pack expansions look
759 // weird to avoid tripping up the type traits in degenerate cases
760 _Lazy<_And,
Louis Dionne574e2e32021-02-10 16:19:50 -0500761 _Not<is_convertible<tuple<_Up>, _Tp> >...,
762 _Not<is_constructible<_Tp, tuple<_Up> > >...
763 >
764 >,
765 is_constructible<_Tp, _Up>...
766 > { };
767
Louis Dionne9ce598d2021-09-08 09:14:43 -0400768 template <class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500769 _And<
770 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
771 _EnableMoveFromOtherTuple<_Up...>,
772 is_convertible<_Up, _Tp>... // explicit check
773 >::value
774 , int> = 0>
Marshall Clow2229cee2013-07-22 16:02:19 +0000775 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Louis Dionne574e2e32021-02-10 16:19:50 -0500776 tuple(tuple<_Up...>&& __t)
777 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
778 : __base_(_VSTD::move(__t))
779 { }
Howard Hinnantc51e1022010-05-11 19:42:16 +0000780
Louis Dionne9ce598d2021-09-08 09:14:43 -0400781 template <class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500782 _And<
783 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
784 _EnableMoveFromOtherTuple<_Up...>,
785 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
786 >::value
787 , int> = 0>
Eric Fiselier8e6a5f02016-04-19 01:19:25 +0000788 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Louis Dionne574e2e32021-02-10 16:19:50 -0500789 explicit tuple(tuple<_Up...>&& __t)
790 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
791 : __base_(_VSTD::move(__t))
792 { }
Eric Fiselier8e6a5f02016-04-19 01:19:25 +0000793
Louis Dionne9ce598d2021-09-08 09:14:43 -0400794 template <class _Alloc, class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500795 _And<
796 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
797 _EnableMoveFromOtherTuple<_Up...>,
798 is_convertible<_Up, _Tp>... // explicit check
799 >::value
800 , int> = 0>
801 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
802 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
803 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
804 { }
Howard Hinnantc51e1022010-05-11 19:42:16 +0000805
Louis Dionne9ce598d2021-09-08 09:14:43 -0400806 template <class _Alloc, class ..._Up, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500807 _And<
808 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
809 _EnableMoveFromOtherTuple<_Up...>,
810 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
811 >::value
812 , int> = 0>
813 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
814 explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
815 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
816 { }
Eric Fiselier8e6a5f02016-04-19 01:19:25 +0000817
Louis Dionne574e2e32021-02-10 16:19:50 -0500818 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
819 template <class _Up1, class _Up2, class ..._DependentTp>
820 struct _EnableImplicitCopyFromPair : _And<
821 is_constructible<_FirstType<_DependentTp...>, const _Up1&>,
822 is_constructible<_SecondType<_DependentTp...>, const _Up2&>,
823 is_convertible<const _Up1&, _FirstType<_DependentTp...> >, // explicit check
824 is_convertible<const _Up2&, _SecondType<_DependentTp...> >
825 > { };
Howard Hinnant65704d02012-04-01 23:10:42 +0000826
Louis Dionne574e2e32021-02-10 16:19:50 -0500827 template <class _Up1, class _Up2, class ..._DependentTp>
828 struct _EnableExplicitCopyFromPair : _And<
829 is_constructible<_FirstType<_DependentTp...>, const _Up1&>,
830 is_constructible<_SecondType<_DependentTp...>, const _Up2&>,
831 _Not<is_convertible<const _Up1&, _FirstType<_DependentTp...> > >, // explicit check
832 _Not<is_convertible<const _Up2&, _SecondType<_DependentTp...> > >
833 > { };
Howard Hinnantc51e1022010-05-11 19:42:16 +0000834
Louis Dionne9ce598d2021-09-08 09:14:43 -0400835 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500836 _And<
837 _BoolConstant<sizeof...(_Tp) == 2>,
838 _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...>
839 >::value
840 , int> = 0>
841 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
842 tuple(const pair<_Up1, _Up2>& __p)
843 _NOEXCEPT_((_And<
844 is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>,
845 is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&>
846 >::value))
847 : __base_(__p)
848 { }
Howard Hinnantc51e1022010-05-11 19:42:16 +0000849
Louis Dionne9ce598d2021-09-08 09:14:43 -0400850 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500851 _And<
852 _BoolConstant<sizeof...(_Tp) == 2>,
853 _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...>
854 >::value
855 , int> = 0>
856 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
857 explicit tuple(const pair<_Up1, _Up2>& __p)
858 _NOEXCEPT_((_And<
859 is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>,
860 is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&>
861 >::value))
862 : __base_(__p)
863 { }
Eric Fiselier8e6a5f02016-04-19 01:19:25 +0000864
Louis Dionne9ce598d2021-09-08 09:14:43 -0400865 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500866 _And<
867 _BoolConstant<sizeof...(_Tp) == 2>,
868 _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...>
869 >::value
870 , int> = 0>
871 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
872 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
873 : __base_(allocator_arg_t(), __a, __p)
874 { }
Howard Hinnantc51e1022010-05-11 19:42:16 +0000875
Louis Dionne9ce598d2021-09-08 09:14:43 -0400876 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500877 _And<
878 _BoolConstant<sizeof...(_Tp) == 2>,
879 _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...>
880 >::value
881 , int> = 0>
882 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
883 explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
884 : __base_(allocator_arg_t(), __a, __p)
885 { }
Howard Hinnant65704d02012-04-01 23:10:42 +0000886
Louis Dionne574e2e32021-02-10 16:19:50 -0500887 // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
888 template <class _Up1, class _Up2, class ..._DependentTp>
889 struct _EnableImplicitMoveFromPair : _And<
890 is_constructible<_FirstType<_DependentTp...>, _Up1>,
891 is_constructible<_SecondType<_DependentTp...>, _Up2>,
892 is_convertible<_Up1, _FirstType<_DependentTp...> >, // explicit check
893 is_convertible<_Up2, _SecondType<_DependentTp...> >
894 > { };
Eric Fiselierec5a2102019-07-12 23:01:48 +0000895
Louis Dionne574e2e32021-02-10 16:19:50 -0500896 template <class _Up1, class _Up2, class ..._DependentTp>
897 struct _EnableExplicitMoveFromPair : _And<
898 is_constructible<_FirstType<_DependentTp...>, _Up1>,
899 is_constructible<_SecondType<_DependentTp...>, _Up2>,
900 _Not<is_convertible<_Up1, _FirstType<_DependentTp...> > >, // explicit check
901 _Not<is_convertible<_Up2, _SecondType<_DependentTp...> > >
902 > { };
Howard Hinnantc51e1022010-05-11 19:42:16 +0000903
Louis Dionne9ce598d2021-09-08 09:14:43 -0400904 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500905 _And<
906 _BoolConstant<sizeof...(_Tp) == 2>,
907 _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>
908 >::value
909 , int> = 0>
Louis Dionne58bca852021-04-30 15:52:26 -0400910 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Louis Dionne574e2e32021-02-10 16:19:50 -0500911 tuple(pair<_Up1, _Up2>&& __p)
912 _NOEXCEPT_((_And<
913 is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
914 is_nothrow_constructible<_SecondType<_Tp...>, _Up2>
915 >::value))
916 : __base_(_VSTD::move(__p))
917 { }
918
Louis Dionne9ce598d2021-09-08 09:14:43 -0400919 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500920 _And<
921 _BoolConstant<sizeof...(_Tp) == 2>,
922 _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>
923 >::value
924 , int> = 0>
Louis Dionne58bca852021-04-30 15:52:26 -0400925 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Louis Dionne574e2e32021-02-10 16:19:50 -0500926 explicit tuple(pair<_Up1, _Up2>&& __p)
927 _NOEXCEPT_((_And<
928 is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
929 is_nothrow_constructible<_SecondType<_Tp...>, _Up2>
930 >::value))
931 : __base_(_VSTD::move(__p))
932 { }
933
Louis Dionne9ce598d2021-09-08 09:14:43 -0400934 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500935 _And<
936 _BoolConstant<sizeof...(_Tp) == 2>,
937 _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>
938 >::value
939 , int> = 0>
940 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
941 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
942 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
943 { }
944
Louis Dionne9ce598d2021-09-08 09:14:43 -0400945 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
Louis Dionne574e2e32021-02-10 16:19:50 -0500946 _And<
947 _BoolConstant<sizeof...(_Tp) == 2>,
948 _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>
949 >::value
950 , int> = 0>
951 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
952 explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
953 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
954 { }
Eric Fiselier8e6a5f02016-04-19 01:19:25 +0000955
Louis Dionne6c0d5342018-07-31 11:56:20 -0400956 // [tuple.assign]
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500957 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne6c0d5342018-07-31 11:56:20 -0400958 tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
959 _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value))
Eric Fiselier737a16d2016-07-25 02:36:42 +0000960 {
Louis Dionne6c0d5342018-07-31 11:56:20 -0400961 _VSTD::__memberwise_copy_assign(*this, __tuple,
962 typename __make_tuple_indices<sizeof...(_Tp)>::type());
Eric Fiselier737a16d2016-07-25 02:36:42 +0000963 return *this;
964 }
965
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500966 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne6c0d5342018-07-31 11:56:20 -0400967 tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
968 _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
Eric Fiselier737a16d2016-07-25 02:36:42 +0000969 {
Louis Dionne6c0d5342018-07-31 11:56:20 -0400970 _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple),
971 __tuple_types<_Tp...>(),
972 typename __make_tuple_indices<sizeof...(_Tp)>::type());
Eric Fiselier737a16d2016-07-25 02:36:42 +0000973 return *this;
974 }
975
Louis Dionne9ce598d2021-09-08 09:14:43 -0400976 template<class... _Up, __enable_if_t<
Louis Dionne6c0d5342018-07-31 11:56:20 -0400977 _And<
978 _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>,
979 is_assignable<_Tp&, _Up const&>...
980 >::value
981 ,int> = 0>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500982 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne6c0d5342018-07-31 11:56:20 -0400983 tuple& operator=(tuple<_Up...> const& __tuple)
984 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
985 {
986 _VSTD::__memberwise_copy_assign(*this, __tuple,
987 typename __make_tuple_indices<sizeof...(_Tp)>::type());
988 return *this;
989 }
Howard Hinnantc51e1022010-05-11 19:42:16 +0000990
Louis Dionne9ce598d2021-09-08 09:14:43 -0400991 template<class... _Up, __enable_if_t<
Louis Dionne6c0d5342018-07-31 11:56:20 -0400992 _And<
993 _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>,
994 is_assignable<_Tp&, _Up>...
995 >::value
996 ,int> = 0>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -0500997 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne6c0d5342018-07-31 11:56:20 -0400998 tuple& operator=(tuple<_Up...>&& __tuple)
999 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
1000 {
1001 _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple),
1002 __tuple_types<_Up...>(),
1003 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1004 return *this;
1005 }
1006
Louis Dionne9ce598d2021-09-08 09:14:43 -04001007 template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t<
Louis Dionne6c0d5342018-07-31 11:56:20 -04001008 _And<_Dep,
1009 _BoolConstant<sizeof...(_Tp) == 2>,
1010 is_assignable<_FirstType<_Tp..., _Dep>&, _Up1 const&>,
1011 is_assignable<_SecondType<_Tp..., _Dep>&, _Up2 const&>
1012 >::value
1013 ,int> = 0>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001014 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne6c0d5342018-07-31 11:56:20 -04001015 tuple& operator=(pair<_Up1, _Up2> const& __pair)
1016 _NOEXCEPT_((_And<
1017 is_nothrow_assignable<_FirstType<_Tp...>&, _Up1 const&>,
1018 is_nothrow_assignable<_SecondType<_Tp...>&, _Up2 const&>
1019 >::value))
1020 {
1021 _VSTD::get<0>(*this) = __pair.first;
1022 _VSTD::get<1>(*this) = __pair.second;
1023 return *this;
1024 }
1025
Louis Dionne9ce598d2021-09-08 09:14:43 -04001026 template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t<
Louis Dionne6c0d5342018-07-31 11:56:20 -04001027 _And<_Dep,
1028 _BoolConstant<sizeof...(_Tp) == 2>,
1029 is_assignable<_FirstType<_Tp..., _Dep>&, _Up1>,
1030 is_assignable<_SecondType<_Tp..., _Dep>&, _Up2>
1031 >::value
1032 ,int> = 0>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001033 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne6c0d5342018-07-31 11:56:20 -04001034 tuple& operator=(pair<_Up1, _Up2>&& __pair)
1035 _NOEXCEPT_((_And<
1036 is_nothrow_assignable<_FirstType<_Tp...>&, _Up1>,
1037 is_nothrow_assignable<_SecondType<_Tp...>&, _Up2>
1038 >::value))
1039 {
Louis Dionne3b8af4d2021-02-24 14:53:21 -05001040 _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first);
1041 _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second);
Louis Dionne6c0d5342018-07-31 11:56:20 -04001042 return *this;
1043 }
1044
1045 // EXTENSION
Louis Dionne9ce598d2021-09-08 09:14:43 -04001046 template<class _Up, size_t _Np, class = __enable_if_t<
Louis Dionne6c0d5342018-07-31 11:56:20 -04001047 _And<
1048 _BoolConstant<_Np == sizeof...(_Tp)>,
1049 is_assignable<_Tp&, _Up const&>...
1050 >::value
1051 > >
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001052 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne6c0d5342018-07-31 11:56:20 -04001053 tuple& operator=(array<_Up, _Np> const& __array)
1054 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
1055 {
1056 _VSTD::__memberwise_copy_assign(*this, __array,
1057 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1058 return *this;
1059 }
1060
1061 // EXTENSION
Louis Dionne9ce598d2021-09-08 09:14:43 -04001062 template<class _Up, size_t _Np, class = void, class = __enable_if_t<
Louis Dionne6c0d5342018-07-31 11:56:20 -04001063 _And<
1064 _BoolConstant<_Np == sizeof...(_Tp)>,
1065 is_assignable<_Tp&, _Up>...
1066 >::value
1067 > >
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001068 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Louis Dionne6c0d5342018-07-31 11:56:20 -04001069 tuple& operator=(array<_Up, _Np>&& __array)
1070 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
1071 {
1072 _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__array),
1073 __tuple_types<_If<true, _Up, _Tp>...>(),
1074 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1075 return *this;
1076 }
1077
1078 // [tuple.swap]
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001079 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Howard Hinnant89ef1212011-05-27 19:08:18 +00001080 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Eric Fiselier3e0d4372017-06-01 02:14:21 +00001081 {__base_.swap(__t.__base_);}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001082};
1083
1084template <>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +00001085class _LIBCPP_TEMPLATE_VIS tuple<>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001086{
1087public:
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001088 _LIBCPP_INLINE_VISIBILITY constexpr
1089 tuple() _NOEXCEPT = default;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001090 template <class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001091 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Howard Hinnant62751642012-07-06 21:53:48 +00001092 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001093 template <class _Alloc>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001094 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Howard Hinnant62751642012-07-06 21:53:48 +00001095 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
Howard Hinnantc834c512011-11-29 18:15:50 +00001096 template <class _Up>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001097 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Howard Hinnant62751642012-07-06 21:53:48 +00001098 tuple(array<_Up, 0>) _NOEXCEPT {}
Howard Hinnantc834c512011-11-29 18:15:50 +00001099 template <class _Alloc, class _Up>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001100 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Howard Hinnant62751642012-07-06 21:53:48 +00001101 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001102 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Howard Hinnant89ef1212011-05-27 19:08:18 +00001103 void swap(tuple&) _NOEXCEPT {}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001104};
1105
Louis Dionned59f8a52021-08-17 11:59:07 -04001106#if _LIBCPP_STD_VER >= 17
Louis Dionne616da2a2019-08-12 18:30:31 +00001107template <class ..._Tp>
1108tuple(_Tp...) -> tuple<_Tp...>;
1109template <class _Tp1, class _Tp2>
1110tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1111template <class _Alloc, class ..._Tp>
1112tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
1113template <class _Alloc, class _Tp1, class _Tp2>
1114tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1115template <class _Alloc, class ..._Tp>
1116tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
Eric Fiselier9a5075c2017-06-08 07:18:17 +00001117#endif
1118
Howard Hinnantc51e1022010-05-11 19:42:16 +00001119template <class ..._Tp>
Arthur O'Dwyer20638cc2021-02-09 19:12:16 -05001120inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Howard Hinnant44267242011-06-01 19:59:32 +00001121typename enable_if
1122<
1123 __all<__is_swappable<_Tp>::value...>::value,
1124 void
1125>::type
Howard Hinnant89ef1212011-05-27 19:08:18 +00001126swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
1127 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
1128 {__t.swap(__u);}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001129
1130// get
1131
1132template <size_t _Ip, class ..._Tp>
Marshall Clow0abb1042013-07-17 18:25:36 +00001133inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant3a47c3d2011-01-24 16:07:25 +00001134typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnant28b24882011-12-01 20:21:04 +00001135get(tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantc51e1022010-05-11 19:42:16 +00001136{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001137 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Eric Fiselier3e0d4372017-06-01 02:14:21 +00001138 return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
Howard Hinnantc51e1022010-05-11 19:42:16 +00001139}
1140
1141template <size_t _Ip, class ..._Tp>
Marshall Clow0abb1042013-07-17 18:25:36 +00001142inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant3a47c3d2011-01-24 16:07:25 +00001143const typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnant28b24882011-12-01 20:21:04 +00001144get(const tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantc51e1022010-05-11 19:42:16 +00001145{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001146 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Eric Fiselier3e0d4372017-06-01 02:14:21 +00001147 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
Howard Hinnantc51e1022010-05-11 19:42:16 +00001148}
1149
Howard Hinnant22e97242010-11-17 19:52:17 +00001150template <size_t _Ip, class ..._Tp>
Marshall Clow0abb1042013-07-17 18:25:36 +00001151inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant3a47c3d2011-01-24 16:07:25 +00001152typename tuple_element<_Ip, tuple<_Tp...> >::type&&
Howard Hinnant28b24882011-12-01 20:21:04 +00001153get(tuple<_Tp...>&& __t) _NOEXCEPT
Howard Hinnant22e97242010-11-17 19:52:17 +00001154{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001155 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantb574f9a2011-01-25 16:31:30 +00001156 return static_cast<type&&>(
Eric Fiselier3e0d4372017-06-01 02:14:21 +00001157 static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
Howard Hinnant22e97242010-11-17 19:52:17 +00001158}
1159
Eric Fiselier6dea8092015-12-18 00:36:55 +00001160template <size_t _Ip, class ..._Tp>
1161inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1162const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1163get(const tuple<_Tp...>&& __t) _NOEXCEPT
1164{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001165 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Eric Fiselier6dea8092015-12-18 00:36:55 +00001166 return static_cast<const type&&>(
Eric Fiselier3e0d4372017-06-01 02:14:21 +00001167 static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
Eric Fiselier6dea8092015-12-18 00:36:55 +00001168}
1169
Marshall Clow15b02e02013-07-13 02:54:05 +00001170#if _LIBCPP_STD_VER > 11
Marshall Clow15b02e02013-07-13 02:54:05 +00001171
Eric Fiselier2d0e2042016-07-02 03:18:30 +00001172namespace __find_detail {
Marshall Clow15b02e02013-07-13 02:54:05 +00001173
Louis Dionne7dd28aa2021-07-20 11:46:05 -04001174static constexpr size_t __not_found = static_cast<size_t>(-1);
Eric Fiselier2d0e2042016-07-02 03:18:30 +00001175static constexpr size_t __ambiguous = __not_found - 1;
Marshall Clow15b02e02013-07-13 02:54:05 +00001176
Eric Fiselier2d0e2042016-07-02 03:18:30 +00001177inline _LIBCPP_INLINE_VISIBILITY
1178constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
1179 return !__matches ? __res :
1180 (__res == __not_found ? __curr_i : __ambiguous);
1181}
Marshall Clow15b02e02013-07-13 02:54:05 +00001182
Eric Fiselier2d0e2042016-07-02 03:18:30 +00001183template <size_t _Nx>
1184inline _LIBCPP_INLINE_VISIBILITY
1185constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1186 return __i == _Nx ? __not_found :
1187 __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
1188}
1189
1190template <class _T1, class ..._Args>
1191struct __find_exactly_one_checked {
Casey Carter7b5a7482017-12-12 17:22:24 +00001192 static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
Eric Fiselier2d0e2042016-07-02 03:18:30 +00001193 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
Casey Carter7b5a7482017-12-12 17:22:24 +00001194 static_assert(value != __not_found, "type not found in type list" );
1195 static_assert(value != __ambiguous, "type occurs more than once in type list");
Eric Fiselier2d0e2042016-07-02 03:18:30 +00001196};
1197
Eric Fiselier8087d302016-07-02 03:46:08 +00001198template <class _T1>
1199struct __find_exactly_one_checked<_T1> {
1200 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1201};
1202
Eric Fiselier2d0e2042016-07-02 03:18:30 +00001203} // namespace __find_detail;
Marshall Clow15b02e02013-07-13 02:54:05 +00001204
1205template <typename _T1, typename... _Args>
Eric Fiselier2d0e2042016-07-02 03:18:30 +00001206struct __find_exactly_one_t
1207 : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
1208};
Marshall Clow15b02e02013-07-13 02:54:05 +00001209
1210template <class _T1, class... _Args>
1211inline _LIBCPP_INLINE_VISIBILITY
1212constexpr _T1& get(tuple<_Args...>& __tup) noexcept
1213{
1214 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1215}
1216
1217template <class _T1, class... _Args>
1218inline _LIBCPP_INLINE_VISIBILITY
1219constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
1220{
1221 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1222}
1223
1224template <class _T1, class... _Args>
1225inline _LIBCPP_INLINE_VISIBILITY
1226constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
1227{
Marshall Clowfe9aa372013-07-15 20:46:11 +00001228 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
Marshall Clow15b02e02013-07-13 02:54:05 +00001229}
1230
Eric Fiselier6dea8092015-12-18 00:36:55 +00001231template <class _T1, class... _Args>
1232inline _LIBCPP_INLINE_VISIBILITY
1233constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1234{
1235 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1236}
1237
Marshall Clow15b02e02013-07-13 02:54:05 +00001238#endif
1239
Howard Hinnantc51e1022010-05-11 19:42:16 +00001240// tie
1241
1242template <class ..._Tp>
Marshall Clowa8892812014-02-25 16:11:46 +00001243inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001244tuple<_Tp&...>
Howard Hinnant62751642012-07-06 21:53:48 +00001245tie(_Tp&... __t) _NOEXCEPT
Howard Hinnantc51e1022010-05-11 19:42:16 +00001246{
1247 return tuple<_Tp&...>(__t...);
1248}
1249
1250template <class _Up>
1251struct __ignore_t
1252{
Howard Hinnantc51e1022010-05-11 19:42:16 +00001253 template <class _Tp>
Eric Fiselier24e70262017-02-06 01:25:31 +00001254 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1255 const __ignore_t& operator=(_Tp&&) const {return *this;}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001256};
1257
Eric Fiselier24e70262017-02-06 01:25:31 +00001258namespace {
Louis Dionne559be102021-09-22 09:35:32 -04001259 constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
Eric Fiselier24e70262017-02-06 01:25:31 +00001260}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001261
Howard Hinnantc51e1022010-05-11 19:42:16 +00001262template <class... _Tp>
Marshall Clow2229cee2013-07-22 16:02:19 +00001263inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Louis Dionnedb1892a2018-12-03 14:03:27 +00001264tuple<typename __unwrap_ref_decay<_Tp>::type...>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001265make_tuple(_Tp&&... __t)
1266{
Louis Dionnedb1892a2018-12-03 14:03:27 +00001267 return tuple<typename __unwrap_ref_decay<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001268}
1269
Howard Hinnant3d203a32010-08-19 18:59:38 +00001270template <class... _Tp>
Marshall Clow2229cee2013-07-22 16:02:19 +00001271inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1272tuple<_Tp&&...>
Howard Hinnant62751642012-07-06 21:53:48 +00001273forward_as_tuple(_Tp&&... __t) _NOEXCEPT
Howard Hinnant3d203a32010-08-19 18:59:38 +00001274{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001275 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnant3d203a32010-08-19 18:59:38 +00001276}
1277
Howard Hinnantc834c512011-11-29 18:15:50 +00001278template <size_t _Ip>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001279struct __tuple_equal
1280{
1281 template <class _Tp, class _Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001282 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001283 bool operator()(const _Tp& __x, const _Up& __y)
1284 {
Marshall Clow60e4aa72014-06-24 00:46:19 +00001285 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001286 }
1287};
1288
1289template <>
1290struct __tuple_equal<0>
1291{
1292 template <class _Tp, class _Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001294 bool operator()(const _Tp&, const _Up&)
1295 {
1296 return true;
1297 }
1298};
1299
1300template <class ..._Tp, class ..._Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001301inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001302bool
1303operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1304{
Marshall Clow8ee1ddd2019-02-07 19:03:48 +00001305 static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
Howard Hinnantc51e1022010-05-11 19:42:16 +00001306 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1307}
1308
Kent Ross0861b0d2021-10-08 14:54:28 -07001309#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR) && !defined(_LIBCPP_HAS_NO_CONCEPTS)
1310
1311// operator<=>
1312
1313template <class ..._Tp, class ..._Up, size_t ..._Is>
1314_LIBCPP_HIDE_FROM_ABI constexpr
1315auto
1316__tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) {
1317 common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal;
1318 static_cast<void>(((__result = _VSTD::__synth_three_way(_VSTD::get<_Is>(__x), _VSTD::get<_Is>(__y)), __result != 0) || ...));
1319 return __result;
1320}
1321
1322template <class ..._Tp, class ..._Up>
1323requires (sizeof...(_Tp) == sizeof...(_Up))
1324_LIBCPP_HIDE_FROM_ABI constexpr
1325common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>
1326operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1327{
1328 return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
1329}
1330
1331#else // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR) && !defined(_LIBCPP_HAS_NO_CONCEPTS)
1332
Howard Hinnantc51e1022010-05-11 19:42:16 +00001333template <class ..._Tp, class ..._Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001334inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001335bool
1336operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1337{
1338 return !(__x == __y);
1339}
1340
Howard Hinnantc834c512011-11-29 18:15:50 +00001341template <size_t _Ip>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001342struct __tuple_less
1343{
1344 template <class _Tp, class _Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001345 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001346 bool operator()(const _Tp& __x, const _Up& __y)
1347 {
Duncan P. N. Exon Smith6d3ec092015-01-21 02:51:17 +00001348 const size_t __idx = tuple_size<_Tp>::value - _Ip;
1349 if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
1350 return true;
1351 if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
1352 return false;
1353 return __tuple_less<_Ip-1>()(__x, __y);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001354 }
1355};
1356
1357template <>
1358struct __tuple_less<0>
1359{
1360 template <class _Tp, class _Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001361 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001362 bool operator()(const _Tp&, const _Up&)
1363 {
1364 return false;
1365 }
1366};
1367
1368template <class ..._Tp, class ..._Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001369inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001370bool
1371operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1372{
Marshall Clow8ee1ddd2019-02-07 19:03:48 +00001373 static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
Howard Hinnantc51e1022010-05-11 19:42:16 +00001374 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1375}
1376
1377template <class ..._Tp, class ..._Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001378inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001379bool
1380operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1381{
1382 return __y < __x;
1383}
1384
1385template <class ..._Tp, class ..._Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001386inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001387bool
1388operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1389{
1390 return !(__x < __y);
1391}
1392
1393template <class ..._Tp, class ..._Up>
Marshall Clow2229cee2013-07-22 16:02:19 +00001394inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantc51e1022010-05-11 19:42:16 +00001395bool
1396operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1397{
1398 return !(__y < __x);
1399}
1400
Kent Ross0861b0d2021-10-08 14:54:28 -07001401#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR) && !defined(_LIBCPP_HAS_NO_CONCEPTS)
1402
Howard Hinnantc51e1022010-05-11 19:42:16 +00001403// tuple_cat
1404
Howard Hinnant6256ee72010-12-11 20:47:50 +00001405template <class _Tp, class _Up> struct __tuple_cat_type;
1406
1407template <class ..._Ttypes, class ..._Utypes>
Howard Hinnant3a47c3d2011-01-24 16:07:25 +00001408struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
Howard Hinnantc51e1022010-05-11 19:42:16 +00001409{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001410 typedef _LIBCPP_NODEBUG tuple<_Ttypes..., _Utypes...> type;
Howard Hinnant6256ee72010-12-11 20:47:50 +00001411};
1412
1413template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1414struct __tuple_cat_return_1
1415{
1416};
1417
1418template <class ..._Types, class _Tuple0>
1419struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1420{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001421 typedef _LIBCPP_NODEBUG typename __tuple_cat_type<tuple<_Types...>,
Eric Fiselier0c8de4b2019-04-26 01:02:18 +00001422 typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type
Howard Hinnant6256ee72010-12-11 20:47:50 +00001423 type;
1424};
1425
1426template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1427struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1428 : public __tuple_cat_return_1<
1429 typename __tuple_cat_type<
1430 tuple<_Types...>,
Eric Fiselier0c8de4b2019-04-26 01:02:18 +00001431 typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type
Howard Hinnant6256ee72010-12-11 20:47:50 +00001432 >::type,
1433 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1434 _Tuple1, _Tuples...>
1435{
1436};
1437
1438template <class ..._Tuples> struct __tuple_cat_return;
1439
1440template <class _Tuple0, class ..._Tuples>
1441struct __tuple_cat_return<_Tuple0, _Tuples...>
1442 : public __tuple_cat_return_1<tuple<>,
1443 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
1444 _Tuples...>
1445{
1446};
1447
1448template <>
1449struct __tuple_cat_return<>
1450{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001451 typedef _LIBCPP_NODEBUG tuple<> type;
Howard Hinnant6256ee72010-12-11 20:47:50 +00001452};
1453
Marshall Clow2229cee2013-07-22 16:02:19 +00001454inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant6256ee72010-12-11 20:47:50 +00001455tuple<>
1456tuple_cat()
1457{
1458 return tuple<>();
Howard Hinnantc51e1022010-05-11 19:42:16 +00001459}
1460
Howard Hinnantc834c512011-11-29 18:15:50 +00001461template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
Howard Hinnant21376f62010-12-12 23:04:37 +00001462struct __tuple_cat_return_ref_imp;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001463
Howard Hinnant21376f62010-12-12 23:04:37 +00001464template <class ..._Types, size_t ..._I0, class _Tuple0>
1465struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001466{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001467 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
Howard Hinnant21376f62010-12-12 23:04:37 +00001468 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1469 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1470};
Howard Hinnantc51e1022010-05-11 19:42:16 +00001471
Howard Hinnant21376f62010-12-12 23:04:37 +00001472template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1473struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1474 _Tuple0, _Tuple1, _Tuples...>
1475 : public __tuple_cat_return_ref_imp<
1476 tuple<_Types..., typename __apply_cv<_Tuple0,
1477 typename tuple_element<_I0,
1478 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1479 typename __make_tuple_indices<tuple_size<typename
1480 remove_reference<_Tuple1>::type>::value>::type,
1481 _Tuple1, _Tuples...>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001482{
Howard Hinnant21376f62010-12-12 23:04:37 +00001483};
1484
1485template <class _Tuple0, class ..._Tuples>
1486struct __tuple_cat_return_ref
1487 : public __tuple_cat_return_ref_imp<tuple<>,
1488 typename __make_tuple_indices<
1489 tuple_size<typename remove_reference<_Tuple0>::type>::value
1490 >::type, _Tuple0, _Tuples...>
1491{
1492};
1493
1494template <class _Types, class _I0, class _J0>
1495struct __tuple_cat;
1496
1497template <class ..._Types, size_t ..._I0, size_t ..._J0>
Howard Hinnant3a47c3d2011-01-24 16:07:25 +00001498struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
Howard Hinnant21376f62010-12-12 23:04:37 +00001499{
1500 template <class _Tuple0>
Marshall Clow2229cee2013-07-22 16:02:19 +00001501 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant21376f62010-12-12 23:04:37 +00001502 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1503 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1504 {
David Blaikie699a5e22019-10-28 18:03:59 -07001505 return _VSTD::forward_as_tuple(
1506 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1507 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
Howard Hinnant21376f62010-12-12 23:04:37 +00001508 }
1509
1510 template <class _Tuple0, class _Tuple1, class ..._Tuples>
Marshall Clow2229cee2013-07-22 16:02:19 +00001511 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant21376f62010-12-12 23:04:37 +00001512 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1513 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1514 {
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001515 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
1516 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1;
Howard Hinnant21376f62010-12-12 23:04:37 +00001517 return __tuple_cat<
David Blaikie699a5e22019-10-28 18:03:59 -07001518 tuple<_Types...,
1519 typename __apply_cv<_Tuple0, typename tuple_element<
1520 _J0, _T0>::type>::type&&...>,
1521 typename __make_tuple_indices<sizeof...(_Types) +
1522 tuple_size<_T0>::value>::type,
1523 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
1524 _VSTD::forward_as_tuple(
1525 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1526 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...),
1527 _VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnant21376f62010-12-12 23:04:37 +00001528 }
1529};
1530
1531template <class _Tuple0, class... _Tuples>
Marshall Clow2229cee2013-07-22 16:02:19 +00001532inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant21376f62010-12-12 23:04:37 +00001533typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1534tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1535{
Louis Dionnea6c4ace2021-08-31 10:32:11 -04001536 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
Howard Hinnant21376f62010-12-12 23:04:37 +00001537 return __tuple_cat<tuple<>, __tuple_indices<>,
1538 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001539 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1540 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001541}
1542
1543template <class ..._Tp, class _Alloc>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +00001544struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001545 : true_type {};
1546
Howard Hinnantc51e1022010-05-11 19:42:16 +00001547template <class _T1, class _T2>
1548template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
Michael Schellenberger Costad41ace62020-09-02 21:20:33 +02001549inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
Howard Hinnantc51e1022010-05-11 19:42:16 +00001550pair<_T1, _T2>::pair(piecewise_construct_t,
1551 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1552 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
Marshall Clow60e4aa72014-06-24 00:46:19 +00001553 : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1554 second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001555{
1556}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001557
Eric Fiselier8e892c52016-07-18 00:35:56 +00001558#if _LIBCPP_STD_VER > 14
1559template <class _Tp>
Louis Dionne559be102021-09-22 09:35:32 -04001560inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
Eric Fiselier8e892c52016-07-18 00:35:56 +00001561
1562#define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1563
1564template <class _Fn, class _Tuple, size_t ..._Id>
1565inline _LIBCPP_INLINE_VISIBILITY
1566constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1567 __tuple_indices<_Id...>)
1568_LIBCPP_NOEXCEPT_RETURN(
1569 _VSTD::__invoke_constexpr(
1570 _VSTD::forward<_Fn>(__f),
1571 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1572)
1573
1574template <class _Fn, class _Tuple>
1575inline _LIBCPP_INLINE_VISIBILITY
1576constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
1577_LIBCPP_NOEXCEPT_RETURN(
1578 _VSTD::__apply_tuple_impl(
1579 _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
Marshall Clowd5bbc242018-02-06 20:56:55 +00001580 typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
Eric Fiselier8e892c52016-07-18 00:35:56 +00001581)
1582
1583template <class _Tp, class _Tuple, size_t... _Idx>
1584inline _LIBCPP_INLINE_VISIBILITY
1585constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1586_LIBCPP_NOEXCEPT_RETURN(
1587 _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
1588)
1589
1590template <class _Tp, class _Tuple>
1591inline _LIBCPP_INLINE_VISIBILITY
1592constexpr _Tp make_from_tuple(_Tuple&& __t)
1593_LIBCPP_NOEXCEPT_RETURN(
1594 _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
Marshall Clowd5bbc242018-02-06 20:56:55 +00001595 typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
Eric Fiselier8e892c52016-07-18 00:35:56 +00001596)
1597
1598#undef _LIBCPP_NOEXCEPT_RETURN
1599
1600#endif // _LIBCPP_STD_VER > 14
1601
Eric Fiselierffe4aba2017-04-19 01:23:39 +00001602#endif // !defined(_LIBCPP_CXX03_LANG)
1603
Howard Hinnantc51e1022010-05-11 19:42:16 +00001604_LIBCPP_END_NAMESPACE_STD
1605
Louis Dionne2b1ceaa2021-04-20 12:03:32 -04001606#endif // _LIBCPP_TUPLE