命名空间
变体
操作

std::in_place, std::in_place_type, std::in_place_index, std::in_place_t, std::in_place_type_t, std::in_place_index_t

来自 cppreference.cn
< cpp‎ | utility
 
 
 
定义于头文件 <utility>
struct in_place_t { explicit in_place_t() = default; };
(1) (自 C++17 起)
inline constexpr std::in_place_t in_place {};
(2) (自 C++17 起)
template< class T >
struct in_place_type_t { explicit in_place_type_t() = default; };
(3) (自 C++17 起)
template< class T >
constexpr std::in_place_type_t<T> in_place_type {};
(4) (自 C++17 起)
template< std::size_t I >
struct in_place_index_t { explicit in_place_index_t() = default; };
(5) (自 C++17 起)
template< std::size_t I >
constexpr std::in_place_index_t<I> in_place_index {};
(6) (自 C++17 起)
1,3,5) 类型/类型模板 std::in_place_tstd::in_place_type_tstd::in_place_index_t 可以用在构造函数的参数列表中,以匹配预期的标签。
2,4,6) 对应的 std::in_placestd::in_place_typestd::in_place_index 实例 (1,3,5) 是消歧义标签,可以传递给构造函数以指示应就地构造包含的对象,并且(对于后两者)要构造的对象的类型。

[编辑] 标准库

以下标准库类型使用 (1-6) 作为消歧义标签

(C++17)
持有任何 CopyConstructible 类型实例的对象
(类) [编辑]
(C++23)
一个包装器,包含预期值或错误值
(类模板) [编辑]
任何可调用对象的仅移动包装器,该对象在给定的调用签名中支持限定符
(类模板) [编辑]
(C++17)
一个可能持有或不持有对象的包装器
(类模板) [编辑]
(C++17)
类型安全的区分联合
(类模板) [编辑]

[编辑] 参见

指示范围内的元素已排序且唯一
(标签)[编辑]
指示范围内的元素已排序(不要求唯一性)
(标签)[编辑]