Lines Matching refs:tuple
1 // <tuple> -*- C++ -*-
25 /** @file include/tuple
57 class tuple;
64 struct __is_empty_non_tuple<tuple<_El0, _El...>> : false_type { };
242 * Contains the actual implementation of the @c tuple template, stored
253 * Recursive tuple implementation. Here we store the @c Head element
607 /// Primary class template, tuple
609 class tuple : public _Tuple_impl<0, _Elements...>
662 // Constraint for tuple(_UTypes&&...) where sizeof...(_UTypes) == 1.
667 && !is_same<tuple, __remove_cvref_t<_Up>>::value;
670 // Constraint for tuple(_UTypes&&...) where sizeof...(_UTypes) > 1.
675 /* Constraint for constructors with a tuple<UTypes...> parameter ensures
677 * tuple(UTypes&&...) or tuple(const tuple&) or tuple(tuple&&).
684 template<typename _Tuple, typename = tuple,
690 // then TUPLE should match tuple(UTypes&&...) instead.
692 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>>
698 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Tp>>
713 tuple()
720 tuple()
727 tuple(const _Elements&... __elements)
734 tuple(const _Elements&... __elements)
742 tuple(_UElements&&... __elements)
750 tuple(_UElements&&... __elements)
754 constexpr tuple(const tuple&) = default;
756 constexpr tuple(tuple&&) = default;
760 && !__use_other_ctor<const tuple<_UElements...>&>(),
763 tuple(const tuple<_UElements...>& __in)
770 && !__use_other_ctor<const tuple<_UElements...>&>(),
773 tuple(const tuple<_UElements...>& __in)
780 && !__use_other_ctor<tuple<_UElements...>&&>(),
783 tuple(tuple<_UElements...>&& __in)
789 && !__use_other_ctor<tuple<_UElements...>&&>(),
792 tuple(tuple<_UElements...>&& __in)
801 tuple(allocator_arg_t __tag, const _Alloc& __a)
808 tuple(allocator_arg_t __tag, const _Alloc& __a)
814 tuple(allocator_arg_t __tag, const _Alloc& __a,
822 tuple(allocator_arg_t __tag, const _Alloc& __a,
830 tuple(allocator_arg_t __tag, const _Alloc& __a,
840 tuple(allocator_arg_t __tag, const _Alloc& __a,
847 tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
852 tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
857 && !__use_other_ctor<const tuple<_UElements...>&>(),
860 tuple(allocator_arg_t __tag, const _Alloc& __a,
861 const tuple<_UElements...>& __in)
868 && !__use_other_ctor<const tuple<_UElements...>&>(),
872 tuple(allocator_arg_t __tag, const _Alloc& __a,
873 const tuple<_UElements...>& __in)
880 && !__use_other_ctor<tuple<_UElements...>&&>(),
883 tuple(allocator_arg_t __tag, const _Alloc& __a,
884 tuple<_UElements...>&& __in)
891 && !__use_other_ctor<tuple<_UElements...>&&>(),
895 tuple(allocator_arg_t __tag, const _Alloc& __a,
896 tuple<_UElements...>&& __in)
901 // tuple assignment
904 tuple&
906 const tuple&,
915 tuple&
917 tuple&&,
927 __enable_if_t<__assignable<const _UElements&...>(), tuple&>
928 operator=(const tuple<_UElements...>& __in)
937 __enable_if_t<__assignable<_UElements...>(), tuple&>
938 operator=(tuple<_UElements...>&& __in)
945 // tuple swap
948 swap(tuple& __in)
955 tuple(_UTypes...) -> tuple<_UTypes...>;
957 tuple(pair<_T1, _T2>) -> tuple<_T1, _T2>;
959 tuple(allocator_arg_t, _Alloc, _UTypes...) -> tuple<_UTypes...>;
961 tuple(allocator_arg_t, _Alloc, pair<_T1, _T2>) -> tuple<_T1, _T2>;
963 tuple(allocator_arg_t, _Alloc, tuple<_UTypes...>) -> tuple<_UTypes...>;
966 // Explicit specialization, zero-element tuple.
968 class tuple<>
972 void swap(tuple&) noexcept { /* no-op */ }
975 tuple() = default;
979 tuple(allocator_arg_t, const _Alloc&) noexcept { }
982 tuple(allocator_arg_t, const _Alloc&, const tuple&) noexcept { }
985 /// Partial specialization, 2-element tuple.
988 class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
1056 tuple()
1063 tuple()
1070 tuple(const _T1& __a1, const _T2& __a2)
1077 tuple(const _T1& __a1, const _T2& __a2)
1084 tuple(_U1&& __a1, _U2&& __a2)
1091 tuple(_U1&& __a1, _U2&& __a2)
1095 constexpr tuple(const tuple&) = default;
1097 constexpr tuple(tuple&&) = default;
1102 tuple(const tuple<_U1, _U2>& __in)
1109 tuple(const tuple<_U1, _U2>& __in)
1116 tuple(tuple<_U1, _U2>&& __in)
1123 tuple(tuple<_U1, _U2>&& __in)
1130 tuple(const pair<_U1, _U2>& __in)
1137 tuple(const pair<_U1, _U2>& __in)
1144 tuple(pair<_U1, _U2>&& __in)
1152 tuple(pair<_U1, _U2>&& __in)
1162 tuple(allocator_arg_t __tag, const _Alloc& __a)
1169 tuple(allocator_arg_t __tag, const _Alloc& __a)
1175 tuple(allocator_arg_t __tag, const _Alloc& __a,
1183 tuple(allocator_arg_t __tag, const _Alloc& __a,
1190 tuple(allocator_arg_t __tag, const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1198 tuple(allocator_arg_t __tag, const _Alloc& __a,
1205 tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
1210 tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
1216 tuple(allocator_arg_t __tag, const _Alloc& __a,
1217 const tuple<_U1, _U2>& __in)
1226 tuple(allocator_arg_t __tag, const _Alloc& __a,
1227 const tuple<_U1, _U2>& __in)
1235 tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in)
1243 tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in)
1250 tuple(allocator_arg_t __tag, const _Alloc& __a,
1258 tuple(allocator_arg_t __tag, const _Alloc& __a,
1265 tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in)
1273 tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in)
1280 tuple&
1282 const tuple&,
1291 tuple&
1293 tuple&&,
1303 __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
1304 operator=(const tuple<_U1, _U2>& __in)
1313 __enable_if_t<__assignable<_U1, _U2>(), tuple&>
1314 operator=(tuple<_U1, _U2>&& __in)
1323 __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
1334 __enable_if_t<__assignable<_U1, _U2>(), tuple&>
1345 swap(tuple& __in)
1354 struct tuple_size<tuple<_Elements...>>
1359 inline constexpr size_t tuple_size_v<tuple<_Types...>>
1363 inline constexpr size_t tuple_size_v<const tuple<_Types...>>
1367 /// Trait to get the Ith element type from a tuple.
1369 struct tuple_element<__i, tuple<_Types...>>
1371 static_assert(__i < sizeof...(_Types), "tuple index must be in range");
1389 __get_helper(const tuple<_Types...>&) = delete;
1391 /// Return a reference to the ith element of a tuple.
1393 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
1394 get(tuple<_Elements...>& __t) noexcept
1397 /// Return a const reference to the ith element of a const tuple.
1399 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&
1400 get(const tuple<_Elements...>& __t) noexcept
1403 /// Return an rvalue reference to the ith element of a tuple rvalue.
1405 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
1406 get(tuple<_Elements...>&& __t) noexcept
1408 typedef __tuple_element_t<__i, tuple<_Elements...>> __element_type;
1412 /// Return a const rvalue reference to the ith element of a const tuple rvalue.
1414 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&&
1415 get(const tuple<_Elements...>&& __t) noexcept
1417 typedef __tuple_element_t<__i, tuple<_Elements...>> __element_type;
1425 get(const tuple<_Elements...>&) = delete;
1432 /// Return a reference to the unique element of type _Tp of a tuple.
1435 get(tuple<_Types...>& __t) noexcept
1439 "the type T in std::get<T> must occur exactly once in the tuple");
1443 /// Return a reference to the unique element of type _Tp of a tuple rvalue.
1446 get(tuple<_Types...>&& __t) noexcept
1450 "the type T in std::get<T> must occur exactly once in the tuple");
1454 /// Return a const reference to the unique element of type _Tp of a tuple.
1457 get(const tuple<_Types...>& __t) noexcept
1461 "the type T in std::get<T> must occur exactly once in the tuple");
1466 /// a const tuple rvalue.
1469 get(const tuple<_Types...>&& __t) noexcept
1473 "the type T in std::get<T> must occur exactly once in the tuple");
1510 operator==(const tuple<_TElements...>& __t,
1511 const tuple<_UElements...>& __u)
1514 "tuple objects can only be compared if they have equal sizes.");
1515 using __compare = __tuple_compare<tuple<_TElements...>,
1516 tuple<_UElements...>,
1543 operator<=>(const tuple<_Tps...>& __t, const tuple<_Ups...>& __u)
1552 operator<(const tuple<_TElements...>& __t,
1553 const tuple<_UElements...>& __u)
1556 "tuple objects can only be compared if they have equal sizes.");
1557 using __compare = __tuple_compare<tuple<_TElements...>,
1558 tuple<_UElements...>,
1565 operator!=(const tuple<_TElements...>& __t,
1566 const tuple<_UElements...>& __u)
1571 operator>(const tuple<_TElements...>& __t,
1572 const tuple<_UElements...>& __u)
1577 operator<=(const tuple<_TElements...>& __t,
1578 const tuple<_UElements...>& __u)
1583 operator>=(const tuple<_TElements...>& __t,
1584 const tuple<_UElements...>& __u)
1589 /// Create a tuple containing copies of the arguments
1591 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
1594 typedef tuple<typename __decay_and_strip<_Elements>::__type...>
1601 /// Create a tuple of lvalue or rvalue references to the arguments
1603 constexpr tuple<_Elements&&...>
1605 { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1608 // std::tuple_cat can use them if <tuple> is included before <array>.
1633 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1635 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1640 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1642 typedef tuple<_Tp...> __type;
1647 : __make_tuple_impl<0, tuple<>, _Tuple, tuple_size<_Tuple>::value>
1650 // Returns the std::tuple equivalent of a tuple-like type.
1656 // Combines several std::tuple's into a single one.
1663 typedef tuple<> __type;
1667 struct __combine_tuples<tuple<_Ts...>>
1669 typedef tuple<_Ts...> __type;
1673 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1675 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1679 // Computes the result type of tuple_cat given a set of tuple-like types.
1687 // Helper to determine the index set for the first tuple-like
1705 // Performs the actual concatenation by step-wise expanding tuple-like
1707 // result tuple.
1738 struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
1742 /// Create a `tuple` containing all elements from multiple tuple-like objects
1757 /// Return a tuple of lvalue references bound to the arguments
1759 constexpr tuple<_Elements&...>
1761 { return tuple<_Elements&...>(__args...); }
1774 swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
1783 swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
1787 // of a tuple is not required.
1800 /** Used with `std::tie` to ignore an element of a tuple
1802 * When using `std::tie` to assign the elements of a tuple to variables,
1819 struct uses_allocator<tuple<_Types...>, _Alloc> : true_type { };
1822 /** "piecewise construction" using a tuple of arguments for each member.
1827 * The elements of each tuple will be used as the constructor arguments
1836 tuple<_Args1...> __first, tuple<_Args2...> __second)
1847 pair(tuple<_Args1...>& __tuple1, tuple<_Args2...>& __tuple2,
1855 // Unpack a std::tuple into a type trait and use its value.
1856 // For cv std::tuple<_Up> the result is _Trait<_Tp, cv _Up...>::value.
1857 // For cv std::tuple<_Up>& the result is _Trait<_Tp, cv _Up&...>::value.
1863 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>>
1867 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&>
1871 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, const tuple<_Up...>>
1875 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, const tuple<_Up...>&>