std::make_optional
STD:使[医]任选
Defined in header | | |
---|---|---|
template< class T > constexpr std::optional<std::decay_t<T>> make_optional( T&& value | (1) | (since C++17) |
template< class T, class... Args > constexpr std::optional<T> make_optional( Args&&... args | (2) | (since C++17) |
template< class T, class U, class... Args > constexpr std::optional<T> make_optional( std::initializer_list<U> il, Args&&... args | (3) | (since C++17) |
1%29从value.有效地打电话std::optional<std::decay_t<T>>(std::forward<T>(value))
2%29从args...相当于returnstd::optional<T>(std::in_place,std::forward<Args>(args)......
3%29从il和args...相当于returnstd::optional<T>(std::in_place, il,std::forward<Args>(args)......
参数
value | - | the value to construct optional object with |
---|---|---|
il, args | - | arguments to be passed to the constructor of T. |
返回值
构造的可选对象。
例外
的构造函数引发的任何异常。T
...
注记
T
由于有保证的复制省略,不必为过载%282-3%29而移动。
另见
(constructor) | constructs the optional object (public member function) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。