首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::make_optional

Defined in header <optional>

?

?

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从ilargs...相当于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)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com