std::experimental::ranges::tagged
来自 cppreference.cn
< cpp | experimental | ranges
template< class Base, TagSpecifier... Tags > requires sizeof...(Tags) <= std::tuple_size<Base>::value |
(ranges TS) | |
类模板 tagged
增强了元组类类型 Base
,它从该类型公开派生,并使用一组由标签说明符 Tags...
指定的命名访问器。标签按顺序应用:Tags...
中的第 i 个标签说明符对应于元组的第 i 个元素。
Tags...
中的标签说明符应是唯一的。否则,行为是未定义的。
无法通过指向除 Base
之外的任何基类的指针删除 tagged
的实例。
目录 |
[编辑] 成员函数
构造一个 tagged 对象(公共成员函数) | |
赋值一个 tagged 对象(公共成员函数) | |
交换两个 tagged 对象的内容(公共成员函数) |
[编辑] 命名元素访问器
对于 Tags...
中第 N 个标签说明符,其对应的元素名称为 name,tagged
提供名为 name 的访问器,如下所示
constexpr decltype(auto) name() & { return std::get<N>(*this); } constexpr decltype(auto) name() const & { return std::get<N>(*this); } constexpr decltype(auto) name() && { return std::get<N>(std::move(*this)); }
[编辑] 非成员函数
为 tagged 对象专门化 swap (函数) |
[编辑] 元组式访问
获取 tagged 的大小(类模板特化) | |
获取 tagged 元素的类型(类模板特化) |
[编辑] 参见
指定类型为标签说明符 (概念) | |
标记 std::pair 的别名模板(别名模板) | |
创建 tagged_pair 的便捷函数(函数模板) | |
标记 std::tuple 的别名模板(别名模板) | |
创建 tagged_tuple 的便捷函数(函数模板) | |
用于 ranges::tagged 的标签说明符(类) |