NexusForce 1.0.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
 从空值构造
NEFORCE_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 >)
 从值显式转换构造
constexpr optional (const T &value) noexcept(is_nothrow_copy_constructible_v< T >)
 从值拷贝构造
constexpr optional (T &&value) noexcept(is_nothrow_move_constructible_v< 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>
NEFORCE_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>
NEFORCE_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>
NEFORCE_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>
NEFORCE_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... >)
 使用初始化列表原位构造
NEFORCE_CONSTEXPR20 ~optional () noexcept
 析构函数
template<typename... Types, enable_if_t< is_constructible_v< T, Types... >, int > = 0>
NEFORCE_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>
NEFORCE_CONSTEXPR20 void emplace (std::initializer_list< U > ilist, Types &&... args) noexcept(is_nothrow_constructible_v< T, std::initializer_list< U > &, Types... >)
 使用初始化列表原位构造值
NEFORCE_CONSTEXPR20 void reset () noexcept
 重置可选值为空
NEFORCE_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(_NEFORCE move(*get_ptr())))> >
 右值转换操作
template<typename F>
constexpr auto transform (F &&f) &&-> optional< remove_cvref_t< decltype(f(_NEFORCE 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
 计算哈希值
NEFORCE_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.hpp70 行定义.

构造及析构函数说明

◆ optional() [1/14]

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

从空值构造

参数
n空值

构造一个空的可选值。

在文件 optional.hpp113 行定义.

引用了 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/14]

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.hpp133 行定义.

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

◆ optional() [3/14]

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)
inlineexplicitconstexprnoexcept

从值显式转换构造

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

在文件 optional.hpp146 行定义.

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

◆ optional() [4/14]

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

从值拷贝构造

参数
value源值

在文件 optional.hpp155 行定义.

引用了 construct(), is_nothrow_copy_constructible_v , 以及 value().

◆ optional() [5/14]

template<typename T>
optional< T >::optional ( T && value)
inlineexplicitconstexprnoexcept

从值移动构造

参数
value源值

在文件 optional.hpp164 行定义.

引用了 construct(), is_nothrow_move_constructible_v, move() , 以及 value().

◆ optional() [6/14]

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.hpp199 行定义.

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

◆ optional() [7/14]

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.hpp214 行定义.

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

◆ optional() [8/14]

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

复制构造函数

参数
other源可选值

在文件 optional.hpp255 行定义.

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

◆ optional() [9/14]

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.hpp292 行定义.

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

◆ optional() [10/14]

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.hpp307 行定义.

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

◆ optional() [11/14]

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

移动构造函数

参数
other源可选值

在文件 optional.hpp346 行定义.

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

◆ optional() [12/14]

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.hpp385 行定义.

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

◆ optional() [13/14]

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.hpp419 行定义.

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

◆ optional() [14/14]

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.hpp434 行定义.

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

成员函数说明

◆ and_then() [1/4]

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

左值然后操作

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

在文件 optional.hpp617 行定义.

引用了 forward().

◆ and_then() [2/4]

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

右值然后操作

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

在文件 optional.hpp645 行定义.

引用了 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.hpp603 行定义.

引用了 forward().

◆ and_then() [4/4]

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

常量右值然后操作

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

在文件 optional.hpp631 行定义.

引用了 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>
NEFORCE_CONSTEXPR20 void optional< T >::emplace ( std::initializer_list< U > ilist,
Types &&... args )
inlinenoexcept

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

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

在文件 optional.hpp467 行定义.

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

◆ emplace() [2/2]

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

原位构造值

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

在文件 optional.hpp451 行定义.

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

被这些函数引用 swap().

◆ has_value()

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

检查是否包含值

返回
是否包含值

在文件 optional.hpp488 行定义.

◆ operator bool()

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

转换为布尔值

返回
是否包含值

在文件 optional.hpp494 行定义.

◆ operator*() [1/4]

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

右值解引用运算符

返回
值的右值引用

在文件 optional.hpp742 行定义.

引用了 move().

◆ operator*() [2/4]

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

左值解引用运算符

返回
值的左值引用

在文件 optional.hpp730 行定义.

◆ operator*() [3/4]

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

常量右值解引用运算符

返回
值的常量右值引用

在文件 optional.hpp736 行定义.

引用了 move().

◆ operator*() [4/4]

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

常量左值解引用运算符

返回
值的常量左值引用

在文件 optional.hpp724 行定义.

◆ operator->() [1/2]

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

常量箭头运算符

返回
指向值的常量指针

在文件 optional.hpp712 行定义.

◆ operator->() [2/2]

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

箭头运算符

返回
指向值的常量指针

在文件 optional.hpp718 行定义.

◆ operator<()

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

小于比较运算符

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

在文件 optional.hpp764 行定义.

引用了 optional().

◆ operator=() [1/7]

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

复制赋值运算符

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

在文件 optional.hpp267 行定义.

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

◆ operator=() [2/7]

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

从引用可选值赋值

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

在文件 optional.hpp399 行定义.

引用了 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>
NEFORCE_CONSTEXPR20 optional & optional< T >::operator= ( const optional< U > & other)
inlinenoexcept

从可选值复制赋值

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

在文件 optional.hpp233 行定义.

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

◆ operator=() [4/7]

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

空值赋值运算符

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

在文件 optional.hpp120 行定义.

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

◆ operator=() [5/7]

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

移动赋值运算符

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

在文件 optional.hpp359 行定义.

引用了 addressof(), 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>
NEFORCE_CONSTEXPR20 optional & optional< T >::operator= ( optional< U > && other)
inlinenoexcept

从可选值移动赋值

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

在文件 optional.hpp324 行定义.

引用了 addressof(), construct(), is_nothrow_assignable_v, is_nothrow_constructible_v, 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>
NEFORCE_CONSTEXPR20 optional & optional< T >::operator= ( U && value)
inlinenoexcept

从值赋值

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

在文件 optional.hpp179 行定义.

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

◆ operator==()

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

等于比较运算符

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

在文件 optional.hpp749 行定义.

引用了 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.hpp589 行定义.

引用了 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.hpp575 行定义.

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

◆ swap()

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

交换两个可选值

参数
other要交换的可选值

在文件 optional.hpp797 行定义.

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

◆ to_hash()

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

计算哈希值

返回
哈希值

在文件 optional.hpp789 行定义.

◆ transform() [1/4]

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

常量右值转换操作

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

在文件 optional.hpp701 行定义.

引用了 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.hpp673 行定义.

引用了 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(_NEFORCE move(*get_ptr())))> >
inlineconstexpr

右值转换操作

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

在文件 optional.hpp687 行定义.

引用了 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.hpp659 行定义.

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

◆ value() [1/4]

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

取出存储的值

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

在文件 optional.hpp513 行定义.

◆ value() [2/4]

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

取出存储的值

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

在文件 optional.hpp537 行定义.

引用了 move().

◆ value() [3/4]

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

取出存储的值

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

在文件 optional.hpp501 行定义.

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

◆ value() [4/4]

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

取出存储的值

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

在文件 optional.hpp525 行定义.

引用了 move().

◆ value_or() [1/2]

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

取出存储的值的移出值

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

在文件 optional.hpp561 行定义.

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

◆ value_or() [2/2]

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

取出存储的值的拷贝值

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

在文件 optional.hpp549 行定义.

引用了 is_nothrow_copy_constructible_v , 以及 value().


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