tuple
标准库标头<tuple>
此标头是一般效用图书馆。
班
*。
元组%28C++11%29实现了固定大小的容器,它包含可能不同类型的元素%28class模板%29
元组[医]Size在编译时获得元组的大小%28类模板专门化%29
元组[医]元素获得指定元素%28类模板专门化%29的类型。
STD::用途[医]分配器<std::tuple>%28C++11%29专门使用std::use[医]分配器类型特征%28类模板专门化%29
常数
在使用Tie%28常数%29解压缩元组时忽略占位符以跳过元素
功能
制造[医]元组创建由参数类型%28函数模板%29定义的类型的元组对象。
Tie创建lvalue引用的元组或将元组解压缩为单个对象%28函数模板%29。
前移[医]如[医]元组创建rvalue引用%28函数模板%29的元组
元组[医]CAT通过连接任意数量的元组%28函数模板%29来创建元组。
获取%28 std::tuple%29元组访问指定元素%28函数模板%29
运算符==运算符%21=运算符<运算符<=运算符>>=按字典顺序比较元组%28函数模板%29中的值
交换%28std::tuple%29%28C++11%29专门使用std::swp算法%28函数模板%29
应用%28C++17%29调用函数元组%28函数模板%29
制造[医]从[医]元组%28C++17%29用参数%28函数模板%29的元组构造对象
简介
二次
namespace std {
// class template tuple:
template <class... Types> class tuple;
// 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<Tuples...> tuple_cat(Tuples&&...
// calling a function with a tuple of arguments
template <class F, class Tuple>
constexpr decltype(auto) apply(F&& f, Tuple&& t
template <class T, class Tuple>
constexpr T make_from_tuple(Tuple&& t
// 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...> >;
// element access:
template <size_t I, class... Types>
constexpr tuple_element_t<I, tuple<Types...>>&
get(tuple<Types...>&) noexcept;
template <size_t I, class... Types>
constexpr tuple_element_t<I, tuple<Types...>>&&
get(tuple<Types...>&&) noexcept;
template <size_t I, class... Types>
constexpr const tuple_element_t<I, tuple<Types...>>&
get(const tuple<Types...>&) noexcept;
template <size_t I, class... Types>
constexpr const tuple_element_t<I, tuple<Types...>>&&
get(const tuple<Types...>&&) noexcept;
template <class T, class... Types>
constexpr T& get(tuple<Types...>& t) noexcept;
template <class T, class... Types>
constexpr T&& get(tuple<Types...>&& t) noexcept;
template <class T, class... Types>
constexpr const T& get(const tuple<Types...>& t) noexcept;
template <class T, class... Types>
constexpr const T&& get(const tuple<Types...>&& t) noexcept;
//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...>&
// allocator-related traits
template <class... Types, class Alloc>
struct uses_allocator<tuple<Types...>, Alloc>;
// specialized algorithms:
template <class... Types>
void swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(x.swap(y)
// tuple helper classes
template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value;
}
二次
类std::tuple
二次
template <class... Types>
class tuple {
public:
// tuple construction
/*conditionally-explicit*/ constexpr tuple(
// only if sizeof...(Types) >= 1
/*conditionally-explicit*/ constexpr tuple(const Types&...
// only if sizeof...(Types) >= 1
template <class... UTypes>
/*conditionally-explicit*/ constexpr tuple(UTypes&&...
tuple(const tuple&) = default;
tuple(tuple&&) = default;
template <class... UTypes>
/*conditionally-explicit*/ constexpr tuple(const tuple<UTypes...>&
template <class... UTypes>
/*conditionally-explicit*/ constexpr tuple(tuple<UTypes...>&&
// only if sizeof...(Types) == 2
template <class U1, class U2>
/*conditionally-explicit*/ constexpr tuple(const pair<U1, U2>&
// only if sizeof...(Types) == 2
template <class U1, class U2>
/*conditionally-explicit*/ constexpr tuple(pair<U1, U2>&&
// allocator-extended constructors
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a
template <class Alloc>
/*conditionally-explicit*/ tuple(allocator_arg_t, const Alloc& a, const Types&...
template <class Alloc, class... UTypes>
/*conditionally-explicit*/ tuple(allocator_arg_t, const Alloc& a, UTypes&&...
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, const tuple&
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, tuple&&
template <class Alloc, class... UTypes>
/*conditionally-explicit*/ tuple(allocator_arg_t,
const Alloc& a, const tuple<UTypes...>&
template <class Alloc, class... UTypes>
/*conditionally-explicit*/ tuple(allocator_arg_t,
const Alloc& a, tuple<UTypes...>&&
template <class Alloc, class U1, class U2>
/*conditionally-explicit*/ tuple(allocator_arg_t,
const Alloc& a, const pair<U1, U2>&
template <class Alloc, class U1, class U2>
/*conditionally-explicit*/ tuple(allocator_arg_t,
const Alloc& a, pair<U1, U2>&&
// tuple assignment
tuple& operator=(const tuple&
tuple& operator=(tuple&&) noexcept(see below
template <class... UTypes>
tuple& operator=(const tuple<UTypes...>&
template <class... UTypes>
tuple& operator=(tuple<UTypes...>&&
template <class U1, class U2>
tuple& operator=(const pair<U1, U2>& // only if sizeof...(Types) == 2
template <class U1, class U2>
tuple& operator=(pair<U1, U2>&& // only if sizeof...(Types) == 2
// tuple swap
void swap(tuple&) noexcept(see below
};
二次
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。