std::experimental::any::any
来自cppreference.com
< cpp | experimental | any
| any() noexcept; |
(1) | (库基础 TS) |
| any( const any& other ); |
(2) | (库基础 TS) |
| any( any&& other ) noexcept; |
(3) | (库基础 TS) |
| template<typename ValueType> any( ValueType&& value ); |
(4) | (库基础 TS) |
构造新的 any 对象。
1) 构造空对象。
2,3) 复制 (2) 或移动 (3) other 的内容进新实例,从而任何内容的类型和值都等于构造函数调用前的 other 所拥有者,或者若 other 为空则内容为空。
4) 构造对象,其初始内容为 std::decay_t<ValueType> 类型对象,从 std::forward<ValueType>(value) 直接初始化它。若 std::is_copy_constructible<std::decay_t<ValueType>>::value 是 false,则程序非良构。此重载只有在 std::decay_t<ValueType> 与 any 并非相同类型时才会参与重载决议。
模板形参
| ValueType | - | 所含的值类型 |
| 类型要求 | ||
-std::decay_t<ValueType> 必须满足可复制构造 (CopyConstructible) 。
| ||
参数
| other | - | 另一个用以复制或移动的 any 对象
|
| value | - | 用以初始化所含值的值 |
异常
2,4) 抛出所含类型的构造函数所抛出的任何异常。
参阅
对 any 对象赋值 (公开成员函数) |