MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
optional< T > 模板类 参考

可选值类 更多...

#include <optional.hpp>

类 optional< T > 继承关系图:
[图例]

Public 成员函数

constexpr optional (none_t n=none) noexcept
 从空值构造
MSTL_CONSTEXPR20 optionaloperator= (none_t n) noexcept
 空值赋值运算符
template<typename U, enable_if_t< is_valid_optional< U >::value &&!is_same_v< remove_cvref_t< U >, optional > &&is_constructible_v< T, U > &&is_convertible_v< U, T >, int > = 0>
constexpr optional (U &&value) noexcept(is_nothrow_constructible_v< T, U >)
 从值隐式转换构造
template<typename U, enable_if_t< is_valid_optional< U >::value &&!is_same_v< remove_cvref_t< U >, optional > &&is_constructible_v< T, U > &&!is_convertible_v< U, T >, int > = 0>
constexpr optional (U &&value) noexcept(is_nothrow_constructible_v< T, U >)
 从值显式转换构造
template<typename U = T, enable_if_t<!is_same_v< remove_cvref_t< U >, optional > &&negation_v< conjunction< is_scalar< T >, is_same< T, decay_t< U > > > > &&is_constructible_v< T, U > &&is_assignable_v< T &, U >, int > = 0>
MSTL_CONSTEXPR20 optionaloperator= (U &&value) noexcept(is_nothrow_constructible_v< T, U > &&is_nothrow_assignable_v< T &, U >)
 从值赋值
template<typename U, enable_if_t<!is_same_v< T, U > &&is_constructible_v< T, const U & > &&is_convertible_v< const U &, T > &&convertible_from_optional< U >::value, int > = 0>
constexpr optional (const optional< U > &other) noexcept(is_nothrow_constructible_v< T, const U & >)
 从可选值隐式转换复制构造
template<typename U, enable_if_t<!is_same_v< T, U > &&is_constructible_v< T, const U & > &&!is_convertible_v< const U &, T > &&convertible_from_optional< U >::value, int > = 0>
constexpr optional (const optional< U > &other) noexcept(is_nothrow_constructible_v< T, const U & >)
 从可选值显式转换复制构造
template<typename U = T, enable_if_t<!is_same_v< remove_cvref_t< U >, optional > &&is_constructible_v< T, const U & > &&is_assignable_v< T &, const U & > &&!convertible_from_optional< U >::value &&!assignable_from_optional< U >::value, int > = 0>
MSTL_CONSTEXPR20 optionaloperator= (const optional< U > &other) noexcept(is_nothrow_constructible_v< T, const U & > &&is_nothrow_assignable_v< T &, const U & >)
 从可选值复制赋值
 optional (const optional &other)
 复制构造函数
optionaloperator= (const optional &other)
 复制赋值运算符
template<typename U, enable_if_t<!is_same_v< T, U > &&is_constructible_v< T, U > &&is_convertible_v< U, T > &&convertible_from_optional< U >::value, int > = 0>
constexpr optional (optional< U > &&other) noexcept(is_nothrow_constructible_v< T, U >)
 从可选值隐式转换移动构造
template<typename U, enable_if_t<!is_same_v< T, U > &&is_constructible_v< T, U > &&!is_convertible_v< U, T > &&convertible_from_optional< U >::value, int > = 0>
constexpr optional (optional< U > &&other) noexcept(is_nothrow_constructible_v< T, U >)
 从可选值显式转换移动构造
template<typename U = T, enable_if_t<!is_same_v< remove_cvref_t< U >, optional > &&is_constructible_v< T, U > &&is_assignable_v< T &, U > &&!convertible_from_optional< U >::value &&!assignable_from_optional< U >::value, int > = 0>
MSTL_CONSTEXPR20 optionaloperator= (optional< U > &&other) noexcept(is_nothrow_constructible_v< T, U > &&is_nothrow_assignable_v< T &, U >)
 从可选值移动赋值
 optional (optional &&other) noexcept
 移动构造函数
optionaloperator= (optional &&other) noexcept
 移动赋值运算符
template<typename U, enable_if_t< is_constructible_v< T, U & >, int > = 0>
constexpr optional (const optional< U & > &other)
 从引用可选值赋值
template<typename U, enable_if_t< is_assignable_v< T &, U & >, int > = 0>
MSTL_CONSTEXPR20 optionaloperator= (const optional< U & > &other)
 从引用可选值赋值
template<typename ... Types, enable_if_t< is_constructible_v< T, Types... >, int > = 0>
constexpr optional (inplace_construct_tag, Types &&... args) noexcept(is_nothrow_constructible_v< T, Types... >)
 原位构造
template<typename U, typename ... Types, enable_if_t< is_constructible_v< T, std::initializer_list< U > &, Types... >, int > = 0>
constexpr optional (inplace_construct_tag, std::initializer_list< U > ilist, Types &&...args) noexcept(is_nothrow_constructible_v< T, std::initializer_list< U > &, Types... >)
 使用初始化列表原位构造
MSTL_CONSTEXPR20 ~optional () noexcept
 析构函数
template<typename... Types, enable_if_t< is_constructible_v< T, Types... >, int > = 0>
MSTL_CONSTEXPR20 void emplace (Types &&... args) noexcept(is_nothrow_constructible_v< T, Types... >)
 原位构造值
template<typename U, typename... Types, enable_if_t< is_constructible_v< T, std::initializer_list< U > &, Types... >, int > = 0>
MSTL_CONSTEXPR20 void emplace (std::initializer_list< U > ilist, Types &&... args) noexcept(is_nothrow_constructible_v< T, std::initializer_list< U > &, Types... >)
 使用初始化列表原位构造值
MSTL_CONSTEXPR20 void reset () noexcept
 重置可选值为空
MSTL_NODISCARD constexpr bool has_value () const noexcept
 检查是否包含值
constexpr operator bool () const noexcept
 转换为布尔值
constexpr const_reference value () const &
 取出存储的值
constexpr reference value () &
 取出存储的值
constexpr const value_type && value () const &&
 取出存储的值
constexpr value_type && value () &&
 取出存储的值
constexpr value_type value_or (value_type value) const &noexcept(is_nothrow_copy_constructible_v< value_type >)
 取出存储的值的拷贝值
constexpr value_type value_or (value_type value) &&noexcept(is_nothrow_move_constructible_v< value_type >)
 取出存储的值的移出值
template<typename F, enable_if_t< is_invocable_v< F > &&is_copy_constructible_v< T >, int > = 0>
constexpr optional or_else (F &&f) const &
 常量左值否则操作
template<typename F, enable_if_t< is_invocable_v< F > &&is_move_constructible_v< T >, int > = 0>
constexpr optional or_else (F &&f) &&
 右值否则操作
template<typename F>
constexpr decltype(auto) and_then (F &&f) const &
 常量左值然后操作
template<typename F>
constexpr decltype(auto) and_then (F &&f) &
 左值然后操作
template<typename F>
constexpr decltype(auto) and_then (F &&f) const &&
 常量右值然后操作
template<typename F>
constexpr decltype(auto) and_then (F &&f) &&
 右值然后操作
template<typename F>
constexpr auto transform (F &&f) const &-> optional< remove_cvref_t< decltype(f(*get_ptr()))> >
 常量左值转换操作
template<typename F>
constexpr auto transform (F &&f) &-> optional< remove_cvref_t< decltype(f(*get_ptr()))> >
 左值转换操作
template<typename F>
constexpr auto transform (F &&f) const &&-> optional< remove_cvref_t< decltype(f(_MSTL move(*get_ptr())))> >
 右值转换操作
template<typename F>
constexpr auto transform (F &&f) &&-> optional< remove_cvref_t< decltype(f(_MSTL move(*get_ptr())))> >
 常量右值转换操作
constexpr const_pointer operator-> () const noexcept
 常量箭头运算符
constexpr pointer operator-> () noexcept
 箭头运算符
constexpr const_reference operator* () const &noexcept
 常量左值解引用运算符
constexpr reference operator* () &noexcept
 左值解引用运算符
constexpr const value_type && operator* () const &&noexcept
 常量右值解引用运算符
constexpr value_type && operator* () &&noexcept
 右值解引用运算符
constexpr bool operator== (const optional &rhs) const noexcept
 等于比较运算符
constexpr bool operator< (const optional &rhs) const noexcept
 小于比较运算符
constexpr size_t to_hash () const noexcept
 计算哈希值
MSTL_CONSTEXPR20 void swap (optional &other) noexcept(is_nothrow_move_constructible_v< T > &&is_nothrow_swappable_v< T >)
 交换两个可选值

详细描述

template<typename T>
class optional< T >

可选值类

模板参数
T存储值的类型

表示一个可能包含值也可能为空的对象。类似于指针,但拥有值语义。

在文件 optional.hpp50 行定义.

构造及析构函数说明

◆ optional() [1/12]

template<typename T>
optional< T >::optional ( none_t n = none)
inlineconstexprnoexcept

从空值构造

参数
n空值

构造一个空的可选值。

在文件 optional.hpp114 行定义.

引用了 none.

被这些函数引用 operator<(), operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), operator==(), optional(), optional(), optional(), optional(), optional(), or_else(), or_else(), swap(), transform(), transform(), transform() , 以及 transform().

◆ optional() [2/12]

template<typename T>
template<typename U, enable_if_t< is_valid_optional< U >::value &&!is_same_v< remove_cvref_t< U >, optional > &&is_constructible_v< T, U > &&is_convertible_v< U, T >, int > = 0>
optional< T >::optional ( U && value)
inlineconstexprnoexcept

从值隐式转换构造

模板参数
U源值类型
参数
value源值

在文件 optional.hpp135 行定义.

引用了 _MSTL, construct(), forward() , 以及 value().

◆ optional() [3/12]

template<typename T>
template<typename U, enable_if_t< is_valid_optional< U >::value &&!is_same_v< remove_cvref_t< U >, optional > &&is_constructible_v< T, U > &&!is_convertible_v< U, T >, int > = 0>
optional< T >::optional ( U && value)
inlineconstexprnoexcept

从值显式转换构造

模板参数
U源值类型
参数
value源值

在文件 optional.hpp149 行定义.

引用了 _MSTL, construct(), forward() , 以及 value().

◆ optional() [4/12]

template<typename T>
template<typename U, enable_if_t<!is_same_v< T, U > &&is_constructible_v< T, const U & > &&is_convertible_v< const U &, T > &&convertible_from_optional< U >::value, int > = 0>
optional< T >::optional ( const optional< U > & other)
inlineconstexprnoexcept

从可选值隐式转换复制构造

模板参数
U源可选值类型
参数
other源可选值

在文件 optional.hpp182 行定义.

引用了 _MSTL, construct() , 以及 optional().

◆ optional() [5/12]

template<typename T>
template<typename U, enable_if_t<!is_same_v< T, U > &&is_constructible_v< T, const U & > &&!is_convertible_v< const U &, T > &&convertible_from_optional< U >::value, int > = 0>
optional< T >::optional ( const optional< U > & other)
inlineexplicitconstexprnoexcept

从可选值显式转换复制构造

模板参数
U源可选值类型
参数
other源可选值

在文件 optional.hpp196 行定义.

引用了 _MSTL, construct() , 以及 optional().

◆ optional() [6/12]

template<typename T>
optional< T >::optional ( const optional< T > & other)
inline

复制构造函数

参数
other源可选值

在文件 optional.hpp232 行定义.

引用了 _MSTL, construct() , 以及 optional().

◆ optional() [7/12]

template<typename T>
template<typename U, enable_if_t<!is_same_v< T, U > &&is_constructible_v< T, U > &&is_convertible_v< U, T > &&convertible_from_optional< U >::value, int > = 0>
optional< T >::optional ( optional< U > && other)
inlineconstexprnoexcept

从可选值隐式转换移动构造

模板参数
U源可选值类型
参数
other源可选值

在文件 optional.hpp266 行定义.

引用了 _MSTL, construct(), move() , 以及 optional().

◆ optional() [8/12]

template<typename T>
template<typename U, enable_if_t<!is_same_v< T, U > &&is_constructible_v< T, U > &&!is_convertible_v< U, T > &&convertible_from_optional< U >::value, int > = 0>
optional< T >::optional ( optional< U > && other)
inlineconstexprnoexcept

从可选值显式转换移动构造

模板参数
U源可选值类型
参数
other源可选值

在文件 optional.hpp280 行定义.

引用了 _MSTL, construct(), move() , 以及 optional().

◆ optional() [9/12]

template<typename T>
optional< T >::optional ( optional< T > && other)
inlinenoexcept

移动构造函数

参数
other源可选值

在文件 optional.hpp316 行定义.

引用了 _MSTL, construct(), move() , 以及 optional().

◆ optional() [10/12]

template<typename T>
template<typename U, enable_if_t< is_constructible_v< T, U & >, int > = 0>
optional< T >::optional ( const optional< U & > & other)
inlineconstexpr

从引用可选值赋值

模板参数
U源引用类型
参数
other源可选值
返回
当前对象的引用

在文件 optional.hpp353 行定义.

引用了 _MSTL, construct() , 以及 optional().

◆ optional() [11/12]

template<typename T>
template<typename ... Types, enable_if_t< is_constructible_v< T, Types... >, int > = 0>
optional< T >::optional ( inplace_construct_tag ,
Types &&... args )
inlineexplicitconstexprnoexcept

原位构造

模板参数
Types参数类型
参数
args构造参数

在文件 optional.hpp387 行定义.

引用了 _MSTL, construct() , 以及 forward().

◆ optional() [12/12]

template<typename T>
template<typename U, typename ... Types, enable_if_t< is_constructible_v< T, std::initializer_list< U > &, Types... >, int > = 0>
optional< T >::optional ( inplace_construct_tag ,
std::initializer_list< U > ilist,
Types &&... args )
inlineexplicitconstexprnoexcept

使用初始化列表原位构造

模板参数
U初始化列表元素类型
Types参数类型
参数
ilist初始化列表
args构造参数

在文件 optional.hpp401 行定义.

引用了 _MSTL, construct() , 以及 forward().

成员函数说明

◆ and_then() [1/4]

template<typename T>
template<typename F>
decltype(auto) optional< T >::and_then ( F && f) &
inlineconstexpr

左值然后操作

模板参数
F函数类型
参数
f函数对象
返回
函数处理存储的值并返回函数结果,或返回函数返回类型的默认构造类型

在文件 optional.hpp591 行定义.

引用了 _MSTL , 以及 forward().

◆ and_then() [2/4]

template<typename T>
template<typename F>
decltype(auto) optional< T >::and_then ( F && f) &&
inlineconstexpr

右值然后操作

模板参数
F函数类型
参数
f函数对象
返回
函数处理存储的值并返回函数结果,或返回函数返回类型的默认构造类型

在文件 optional.hpp619 行定义.

引用了 _MSTL, forward() , 以及 move().

◆ and_then() [3/4]

template<typename T>
template<typename F>
decltype(auto) optional< T >::and_then ( F && f) const &
inlineconstexpr

常量左值然后操作

模板参数
F函数类型
参数
f函数对象
返回
函数处理存储的值并返回函数结果,或返回函数返回类型的默认构造类型

在文件 optional.hpp577 行定义.

引用了 _MSTL , 以及 forward().

◆ and_then() [4/4]

template<typename T>
template<typename F>
decltype(auto) optional< T >::and_then ( F && f) const &&
inlineconstexpr

常量右值然后操作

模板参数
F函数类型
参数
f函数对象
返回
函数处理存储的值并返回函数结果,或返回函数返回类型的默认构造类型

在文件 optional.hpp605 行定义.

引用了 _MSTL, forward() , 以及 move().

◆ emplace() [1/2]

template<typename T>
template<typename U, typename... Types, enable_if_t< is_constructible_v< T, std::initializer_list< U > &, Types... >, int > = 0>
MSTL_CONSTEXPR20 void optional< T >::emplace ( std::initializer_list< U > ilist,
Types &&... args )
inlinenoexcept

使用初始化列表原位构造值

模板参数
U初始化列表元素类型
Types参数类型
参数
ilist初始化列表
args构造参数

在文件 optional.hpp436 行定义.

引用了 _MSTL, construct(), forward() , 以及 reset().

◆ emplace() [2/2]

template<typename T>
template<typename... Types, enable_if_t< is_constructible_v< T, Types... >, int > = 0>
MSTL_CONSTEXPR20 void optional< T >::emplace ( Types &&... args)
inlinenoexcept

原位构造值

模板参数
Types参数类型
参数
args构造参数

在文件 optional.hpp420 行定义.

引用了 _MSTL, construct(), forward() , 以及 reset().

被这些函数引用 swap().

◆ has_value()

template<typename T>
MSTL_NODISCARD constexpr bool optional< T >::has_value ( ) const
inlineconstexprnoexcept

检查是否包含值

返回
是否包含值

在文件 optional.hpp454 行定义.

◆ operator bool()

template<typename T>
optional< T >::operator bool ( ) const
inlineexplicitconstexprnoexcept

转换为布尔值

返回
是否包含值

在文件 optional.hpp462 行定义.

◆ operator*() [1/4]

template<typename T>
value_type && optional< T >::operator* ( ) &&
inlineconstexprnoexcept

右值解引用运算符

返回
值的右值引用

在文件 optional.hpp716 行定义.

引用了 _MSTL , 以及 move().

◆ operator*() [2/4]

template<typename T>
reference optional< T >::operator* ( ) &
inlineconstexprnoexcept

左值解引用运算符

返回
值的左值引用

在文件 optional.hpp704 行定义.

◆ operator*() [3/4]

template<typename T>
const value_type && optional< T >::operator* ( ) const &&
inlineconstexprnoexcept

常量右值解引用运算符

返回
值的常量右值引用

在文件 optional.hpp710 行定义.

引用了 _MSTL , 以及 move().

◆ operator*() [4/4]

template<typename T>
const_reference optional< T >::operator* ( ) const &
inlineconstexprnoexcept

常量左值解引用运算符

返回
值的常量左值引用

在文件 optional.hpp698 行定义.

◆ operator->() [1/2]

template<typename T>
const_pointer optional< T >::operator-> ( ) const
inlineconstexprnoexcept

常量箭头运算符

返回
指向值的常量指针

在文件 optional.hpp686 行定义.

◆ operator->() [2/2]

template<typename T>
pointer optional< T >::operator-> ( )
inlineconstexprnoexcept

箭头运算符

返回
指向值的常量指针

在文件 optional.hpp692 行定义.

◆ operator<()

template<typename T>
bool optional< T >::operator< ( const optional< T > & rhs) const
inlineconstexprnoexcept

小于比较运算符

参数
rhs右操作数
返回
当前值是否小于右操作数值

在文件 optional.hpp738 行定义.

引用了 optional().

◆ operator=() [1/7]

template<typename T>
optional & optional< T >::operator= ( const optional< T > & other)
inline

复制赋值运算符

参数
other源可选值
返回
当前对象的引用

在文件 optional.hpp244 行定义.

引用了 _MSTL, addressof(), construct(), optional() , 以及 reset().

◆ operator=() [2/7]

template<typename T>
template<typename U, enable_if_t< is_assignable_v< T &, U & >, int > = 0>
MSTL_CONSTEXPR20 optional & optional< T >::operator= ( const optional< U & > & other)
inline

从引用可选值赋值

模板参数
U源引用类型
参数
other源可选值
返回
当前对象的引用

在文件 optional.hpp367 行定义.

引用了 _MSTL, construct(), optional() , 以及 reset().

◆ operator=() [3/7]

template<typename T>
template<typename U = T, enable_if_t<!is_same_v< remove_cvref_t< U >, optional > &&is_constructible_v< T, const U & > &&is_assignable_v< T &, const U & > &&!convertible_from_optional< U >::value &&!assignable_from_optional< U >::value, int > = 0>
MSTL_CONSTEXPR20 optional & optional< T >::operator= ( const optional< U > & other)
inlinenoexcept

从可选值复制赋值

模板参数
U源可选值类型
参数
other源可选值
返回
当前对象的引用

在文件 optional.hpp212 行定义.

引用了 _MSTL, addressof(), construct(), optional() , 以及 reset().

◆ operator=() [4/7]

template<typename T>
MSTL_CONSTEXPR20 optional & optional< T >::operator= ( none_t n)
inlinenoexcept

空值赋值运算符

参数
n空值标签
返回
当前对象的引用

在文件 optional.hpp121 行定义.

引用了 optional() , 以及 reset().

◆ operator=() [5/7]

template<typename T>
optional & optional< T >::operator= ( optional< T > && other)
inlinenoexcept

移动赋值运算符

参数
other源可选值
返回
当前对象的引用

在文件 optional.hpp329 行定义.

引用了 _MSTL, construct(), move(), optional() , 以及 reset().

◆ operator=() [6/7]

template<typename T>
template<typename U = T, enable_if_t<!is_same_v< remove_cvref_t< U >, optional > &&is_constructible_v< T, U > &&is_assignable_v< T &, U > &&!convertible_from_optional< U >::value &&!assignable_from_optional< U >::value, int > = 0>
MSTL_CONSTEXPR20 optional & optional< T >::operator= ( optional< U > && other)
inlinenoexcept

从可选值移动赋值

模板参数
U源可选值类型
参数
other源可选值
返回
当前对象的引用

在文件 optional.hpp296 行定义.

引用了 _MSTL, addressof(), construct(), move(), optional() , 以及 reset().

◆ operator=() [7/7]

template<typename T>
template<typename U = T, enable_if_t<!is_same_v< remove_cvref_t< U >, optional > &&negation_v< conjunction< is_scalar< T >, is_same< T, decay_t< U > > > > &&is_constructible_v< T, U > &&is_assignable_v< T &, U >, int > = 0>
MSTL_CONSTEXPR20 optional & optional< T >::operator= ( U && value)
inlinenoexcept

从值赋值

模板参数
U源值类型
参数
value源值
返回
当前对象的引用

在文件 optional.hpp163 行定义.

引用了 _MSTL, construct(), forward(), move(), optional() , 以及 value().

◆ operator==()

template<typename T>
bool optional< T >::operator== ( const optional< T > & rhs) const
inlineconstexprnoexcept

等于比较运算符

参数
rhs右操作数
返回
两个可选值是否相等

在文件 optional.hpp723 行定义.

引用了 optional().

◆ or_else() [1/2]

template<typename T>
template<typename F, enable_if_t< is_invocable_v< F > &&is_move_constructible_v< T >, int > = 0>
optional optional< T >::or_else ( F && f) &&
inlineconstexpr

右值否则操作

模板参数
F函数类型
参数
f函数对象
返回
值存在时返回自身的移动,不存在时调用函数并返回结果

在文件 optional.hpp563 行定义.

引用了 _MSTL, forward(), move() , 以及 optional().

◆ or_else() [2/2]

template<typename T>
template<typename F, enable_if_t< is_invocable_v< F > &&is_copy_constructible_v< T >, int > = 0>
optional optional< T >::or_else ( F && f) const &
inlineconstexpr

常量左值否则操作

模板参数
F函数类型
参数
f函数对象
返回
值存在时返回自身的拷贝,不存在时调用函数并返回结果

在文件 optional.hpp548 行定义.

引用了 _MSTL, forward() , 以及 optional().

◆ swap()

template<typename T>
MSTL_CONSTEXPR20 void optional< T >::swap ( optional< T > & other)
inlinenoexcept

交换两个可选值

参数
other要交换的可选值

在文件 optional.hpp783 行定义.

引用了 _MSTL, addressof(), emplace(), move(), optional(), reset() , 以及 swap().

◆ to_hash()

template<typename T>
size_t optional< T >::to_hash ( ) const
inlineconstexprnoexcept

计算哈希值

返回
哈希值

在文件 optional.hpp775 行定义.

引用了 _CONSTANTS.

◆ transform() [1/4]

template<typename T>
template<typename F>
auto optional< T >::transform ( F && f) && -> optional< remove_cvref_t< decltype(f(_MSTL move(*get_ptr())))> >
inlineconstexpr

常量右值转换操作

模板参数
F函数类型
参数
f函数对象
返回
函数处理存储的值的移动并返回新的optional,或返回none的optional

在文件 optional.hpp675 行定义.

引用了 _MSTL, forward(), move(), none , 以及 optional().

◆ transform() [2/4]

template<typename T>
template<typename F>
auto optional< T >::transform ( F && f) & -> optional< remove_cvref_t< decltype(f(*get_ptr()))> >
inlineconstexpr

左值转换操作

模板参数
F函数类型
参数
f函数对象
返回
函数处理存储的值并返回新的optional,或返回none的optional

在文件 optional.hpp647 行定义.

引用了 _MSTL, forward(), none , 以及 optional().

◆ transform() [3/4]

template<typename T>
template<typename F>
auto optional< T >::transform ( F && f) const && -> optional< remove_cvref_t< decltype(f(_MSTL move(*get_ptr())))> >
inlineconstexpr

右值转换操作

模板参数
F函数类型
参数
f函数对象
返回
函数处理存储的值的移动并返回新的optional,或返回none的optional

在文件 optional.hpp661 行定义.

引用了 _MSTL, forward(), move(), none , 以及 optional().

◆ transform() [4/4]

template<typename T>
template<typename F>
auto optional< T >::transform ( F && f) const & -> optional< remove_cvref_t< decltype(f(*get_ptr()))> >
inlineconstexpr

常量左值转换操作

模板参数
F函数类型
参数
f函数对象
返回
函数处理存储的值并返回新的optional,或返回none的optional

在文件 optional.hpp633 行定义.

引用了 _MSTL, forward(), none , 以及 optional().

◆ value() [1/4]

template<typename T>
reference optional< T >::value ( ) &
inlineconstexpr

取出存储的值

返回
存储的值的左值引用
异常
optional_exception如果值未存储

在文件 optional.hpp483 行定义.

◆ value() [2/4]

template<typename T>
value_type && optional< T >::value ( ) &&
inlineconstexpr

取出存储的值

返回
存储的值的右值引用
异常
optional_exception如果值未存储

在文件 optional.hpp507 行定义.

引用了 _MSTL , 以及 move().

◆ value() [3/4]

template<typename T>
const_reference optional< T >::value ( ) const &
inlineconstexpr

取出存储的值

返回
存储的值的常量左值引用
异常
optional_exception如果值未存储

在文件 optional.hpp471 行定义.

被这些函数引用 get(), get(), get(), get(), make_optional(), make_optional(), operator=(), optional(), value_or() , 以及 value_or().

◆ value() [4/4]

template<typename T>
const value_type && optional< T >::value ( ) const &&
inlineconstexpr

取出存储的值

返回
存储的值的常量右值引用
异常
optional_exception如果值未存储

在文件 optional.hpp495 行定义.

引用了 _MSTL , 以及 move().

◆ value_or() [1/2]

template<typename T>
value_type optional< T >::value_or ( value_type value) &&
inlineconstexprnoexcept

取出存储的值的移出值

参数
value值不存在时返回的值
返回
值存在时返回其值的引用,不存在时返回参数value

在文件 optional.hpp532 行定义.

引用了 _MSTL, move() , 以及 value().

◆ value_or() [2/2]

template<typename T>
value_type optional< T >::value_or ( value_type value) const &
inlineconstexprnoexcept

取出存储的值的拷贝值

参数
value值不存在时返回的值
返回
值存在时返回其值的拷贝,不存在时返回参数value

在文件 optional.hpp519 行定义.

引用了 value().


该类的文档由以下文件生成: