This subclause describes the tuple library that provides a tuple type as the class template tuple that can be instantiated with any number of arguments. Each template argument specifies the type of an element in the tuple. Consequently, tuples are heterogeneous, fixed-size collections of values. An instantiation of tuple with two arguments is similar to an instantiation of pair with the same two arguments. See [pairs].
Header <tuple> synopsis
namespace std { // [tuple.tuple], class template tuple: template <class... Types> class tuple; // [tuple.creation], tuple creation functions: const unspecified ignore; template <class... Types> tuple<VTypes...> make_tuple(Types&&...); template <class... Types> tuple<Types...> forward_as_tuple(Types&&...) noexcept; template<class... Types> tuple<Types&...> tie(Types&...) noexcept; template <class... Tuples> tuple<Ctypes...> tuple_cat(Tuples&&...); // [tuple.helper], tuple helper classes: template <class T> class tuple_size; // undefined template <class T> class tuple_size<const T>; template <class T> class tuple_size<volatile T>; template <class T> class tuple_size<const volatile T>; template <class... Types> class tuple_size<tuple<Types...> >; template <size_t I, class T> class tuple_element; // undefined template <size_t I, class T> class tuple_element<I, const T>; template <size_t I, class T> class tuple_element<I, volatile T>; template <size_t I, class T> class tuple_element<I, const volatile T>; template <size_t I, class... Types> class tuple_element<I, tuple<Types...> >; // [tuple.elem], element access: template <size_t I, class... Types> typename tuple_element<I, tuple<Types...> >::type& get(tuple<Types...>&) noexcept; template <size_t I, class... types> typename tuple_element<I, tuple<Types...> >::type&& get(tuple<Types...>&&) noexcept; template <size_t I, class... types> typename tuple_element<I, tuple<Types...> >::type const& get(const tuple<Types...>&) noexcept; // [tuple.rel], relational operators: template<class... TTypes, class... UTypes> bool operator==(const tuple<TTypes...>&, const tuple<UTypes...>&); template<class... TTypes, class... UTypes> bool operator<(const tuple<TTypes...>&, const tuple<UTypes...>&); template<class... TTypes, class... UTypes> bool operator!=(const tuple<TTypes...>&, const tuple<UTypes...>&); template<class... TTypes, class... UTypes> bool operator>(const tuple<TTypes...>&, const tuple<UTypes...>&); template<class... TTypes, class... UTypes> bool operator<=(const tuple<TTypes...>&, const tuple<UTypes...>&); template<class... TTypes, class... UTypes> bool operator>=(const tuple<TTypes...>&, const tuple<UTypes...>&); // [tuple.traits], allocator-related traits template <class... Types, class Alloc> struct uses_allocator<tuple<Types...>, Alloc>; // [tuple.special], specialized algorithms: template <class... Types> void swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(see below); }