DtkCore
DTK Core module
载入中...
搜索中...
未找到
Dtk::Core::DExpected< T, E > 模板类 参考

模板类Dtk::Core::DExpected提供存储两个值之一的方式。Dtk::Core::DExpected的对象要么保有一个期待的T类型值,要么保有一个不期待的E类型值,不会没有值。 更多...

#include <dexpected.h>

Public 类型

using value_type = T
 
using error_type = E
 
using dunexpected_type = DUnexpected< E >
 
template<typename U >
using rebind = DExpected< U, error_type >
 

Public 成员函数

template<typename std::enable_if< std::is_default_constructible< T >::value, bool >::type = true>
constexpr DExpected () noexcept(std::is_nothrow_default_constructible< T >::value)
 Dtk::Core::DExpected的默认构造函数
 
template<typename std::enable_if< std::is_copy_constructible< T >::value and std::is_copy_constructible< E >::value, bool >::type = true>
 DExpected (const DExpected &_x) noexcept(std::is_nothrow_copy_constructible< T >::value and std::is_nothrow_copy_constructible< E >::value)
 Dtk::Core::DExpected的拷贝构造函数
 
template<typename std::enable_if< std::is_move_constructible< T >::value and std::is_move_constructible< E >::value, bool >::type = true>
 DExpected (DExpected &&_x) noexcept(std::is_nothrow_move_constructible< T >::value and std::is_nothrow_move_constructible< E >::value)
 Dtk::Core::DExpected的移动构造函数
 
template<typename U , typename G , typename std::enable_if< std::is_constructible< T, const U & >::value and std::is_constructible< E, const G & >::value and !__cons_from_DExpected< U, G >() and !__explicit_conv< const U &, const G & >(), bool >::type = true>
 DExpected (const DExpected< U, G > &_x) noexcept(std::is_nothrow_constructible< T, const U & >::value and std::is_nothrow_constructible< E, const G & >::value)
 Dtk::Core::DExpected的拷贝构造函数
 
template<typename U , typename G , typename std::enable_if< std::is_constructible< T, const U & >::value and std::is_constructible< E, const G & >::value and !__cons_from_DExpected< U, G >() and __explicit_conv< const U &, const G & >(), bool >::type = true>
 DExpected (const DExpected< U, G > &_x) noexcept(std::is_nothrow_constructible< T, const U & >::value and std::is_nothrow_constructible< E, const G & >::value)
 Dtk::Core::DExpected的拷贝构造函数
 
template<typename U , typename G , typename std::enable_if< std::is_constructible< T, U >::value and std::is_constructible< E, G >::value and !__cons_from_DExpected< U, G >() and !__explicit_conv< U, G >(), bool >::type = true>
 DExpected (DExpected< U, G > &&_x) noexcept(std::is_nothrow_constructible< T, U >::value and std::is_nothrow_constructible< E, G >::value)
 Dtk::Core::DExpected的移动构造函数
 
template<typename U , typename G , typename std::enable_if< std::is_constructible< T, U >::value and std::is_constructible< E, G >::value and !__cons_from_DExpected< U, G >() and __explicit_conv< U, G >(), bool >::type = true>
 DExpected (DExpected< U, G > &&_x) noexcept(std::is_nothrow_constructible< T, U >::value and std::is_nothrow_constructible< E, G >::value)
 Dtk::Core::DExpected的移动构造函数
 
template<typename U = T, typename std::enable_if<!std::is_same< typename remove_cvref< U >::type, DExpected >::value and !std::is_same< typename remove_cvref< U >::type, emplace_tag >::value and !__dexpected::_is_dunexpected< typename remove_cvref< U >::type >::value and std::is_constructible< T, U >::value and !std::is_convertible< U, T >::value, bool >::type = true>
constexpr DExpected (U &&_v) noexcept(std::is_nothrow_constructible< T, U >::value)
 Dtk::Core::DExpected的移动构造函数,直接从期待类型构造出Dtk::Core::DExpected对象
 
template<typename U = T, typename std::enable_if<!std::is_same< typename remove_cvref< U >::type, DExpected >::value and !std::is_same< typename remove_cvref< U >::type, emplace_tag >::value and !__dexpected::_is_dunexpected< typename remove_cvref< U >::type >::value and std::is_constructible< T, U >::value and std::is_convertible< U, T >::value, bool >::type = true>
constexpr DExpected (U &&_v) noexcept(std::is_nothrow_constructible< T, U >::value)
 Dtk::Core::DExpected的移动构造函数,直接从期待类型构造出Dtk::Core::DExpected对象
 
template<typename G = E, typename std::enable_if< std::is_constructible< E, const G & >::value and !std::is_convertible< const G &, E >::value, bool >::type = true>
constexpr DExpected (const DUnexpected< G > &_u) noexcept(std::is_nothrow_constructible< E, const G & >::value)
 Dtk::Core::DExpected的拷贝构造函数,从Dtk::Core::DUnexpected构造出Dtk::Core::DExpected对象
 
template<typename G = E, typename std::enable_if< std::is_constructible< E, const G & >::value and std::is_convertible< const G &, E >::value, bool >::type = true>
constexpr DExpected (const DUnexpected< G > &_u) noexcept(std::is_nothrow_constructible< E, const G & >::value)
 Dtk::Core::DExpected的拷贝构造函数,从Dtk::Core::DUnexpected构造出Dtk::Core::DExpected对象
 
template<typename G = E, typename std::enable_if< std::is_constructible< E, G >::value and !std::is_convertible< G, E >::value, bool >::type = true>
constexpr DExpected (DUnexpected< G > &&_u) noexcept(std::is_nothrow_constructible< E, G >::value)
 Dtk::Core::DExpected的移动构造函数,从Dtk::Core::DUnexpected构造出Dtk::Core::DExpected对象
 
template<typename G = E, typename std::enable_if< std::is_constructible< E, G >::value and std::is_convertible< G, E >::value, bool >::type = true>
constexpr DExpected (DUnexpected< G > &&_u) noexcept(std::is_nothrow_constructible< E, G >::value)
 Dtk::Core::DExpected的移动构造函数,从Dtk::Core::DUnexpected构造出Dtk::Core::DExpected对象
 
template<typename... Args>
constexpr DExpected (emplace_tag, Args &&...args) noexcept(std::is_nothrow_constructible< T, Args... >::value)
 Dtk::Core::DExpected的转发构造函数,从参数直接构造出期待值
 
template<typename U , typename... Args>
constexpr DExpected (emplace_tag, std::initializer_list< U > _li, Args &&...args) noexcept(std::is_nothrow_constructible< T, std::initializer_list< U > &, Args... >::value)
 Dtk::Core::DExpected的转发构造函数,从参数直接构造出期待值
 
template<typename... Args>
constexpr DExpected (dunexpected_tag, Args &&...args) noexcept(std::is_nothrow_constructible< E, Args... >::value)
 Dtk::Core::DExpected的转发构造函数,从参数直接构造出不期待值
 
template<typename U , typename... Args>
constexpr DExpected (dunexpected_tag, std::initializer_list< U > _li, Args &&...args) noexcept(std::is_nothrow_constructible< E, std::initializer_list< U > &, Args... >::value)
 Dtk::Core::DExpected的转发构造函数,从参数直接构造出不期待值
 
 ~DExpected ()
 Dtk::Core::DExpected的析构函数
 
DExpectedoperator= (const DExpected &)=delete
 Dtk::Core::DExpected的默认拷贝赋值运算符
 
template<typename std::enable_if< std::is_copy_assignable< T >::value and std::is_copy_constructible< T >::value and std::is_copy_assignable< E >::value and std::is_copy_constructible< E >::value and(std::is_nothrow_move_constructible< T >::value or std::is_nothrow_move_constructible< E >::value), bool >::type = true>
DExpectedoperator= (const DExpected &_x) noexcept(std::is_nothrow_copy_constructible< T >::value and std::is_nothrow_copy_constructible< E >::value and std::is_nothrow_copy_assignable< T >::value and std::is_nothrow_copy_assignable< E >::value)
 Dtk::Core::DExpected的拷贝赋值运算符
 
template<typename std::enable_if< std::is_move_assignable< T >::value and std::is_move_constructible< T >::value and std::is_move_assignable< E >::value and std::is_move_constructible< E >::value and(std::is_nothrow_move_constructible< T >::value or std::is_nothrow_move_constructible< E >::value), bool >::type = true>
DExpectedoperator= (DExpected &&_x) noexcept(std::is_nothrow_move_constructible< T >::value and std::is_nothrow_move_constructible< E >::value and std::is_nothrow_move_assignable< T >::value and std::is_nothrow_move_assignable< E >::value)
 Dtk::Core::DExpected的移动赋值运算符
 
template<typename U = T, typename std::enable_if<!std::is_same< DExpected, typename remove_cvref< U >::type >::value and !__dexpected::_is_dunexpected< typename remove_cvref< U >::type >::value and std::is_constructible< T, U >::value and std::is_assignable< T &, U >::value and(std::is_nothrow_constructible< T, U >::value or std::is_nothrow_move_constructible< T >::value or std::is_nothrow_move_constructible< E >::value), bool >::type = true>
DExpectedoperator= (U &&_v)
 Dtk::Core::DExpected的转发赋值运算符
 
template<typename G , typename std::enable_if< std::is_constructible< E, const G & >::value and std::is_assignable< E &, const G & >::value and(std::is_nothrow_constructible< E, const G & >::value or std::is_nothrow_move_constructible< T >::value or std::is_move_constructible< E >::value), bool >::type = true>
DExpectedoperator= (const DUnexpected< G > &_e)
 Dtk::Core::DExpected的拷贝赋值运算符
 
template<typename G , typename std::enable_if< std::is_constructible< E, G >::value and std::is_assignable< E &, G >::value and(std::is_nothrow_constructible< E, G >::value or std::is_nothrow_move_constructible< T >::value or std::is_move_constructible< E >::value), bool >::type = true>
DExpectedoperator= (DUnexpected< G > &&_e)
 Dtk::Core::DExpected的移动赋值运算符
 
template<typename... Args>
T & emplace (Args &&...args) noexcept
 从参数直接转发构造期待值
 
template<typename U , typename... Args>
T & emplace (std::initializer_list< U > li, Args &&...args) noexcept
 从参数直接转发构造期待值
 
template<typename std::enable_if< std::is_move_constructible< T >::value and std::is_move_constructible< E >::value and(std::is_nothrow_move_constructible< T >::value or std::is_nothrow_move_constructible< E >::value), bool >::type = true>
void swap (DExpected &_x) noexcept(std::is_nothrow_move_constructible< T >::value and std::is_nothrow_move_constructible< E >::value)
 交换两个Dtk::Core::DExpected的值
 
const T * operator-> () const noexcept
 重载箭头运算符
 
T * operator-> () noexcept
 重载箭头运算符
 
const T & operator* () const &noexcept
 重载解引用运算符
 
T & operator* () &noexcept
 重载解引用运算符
 
const T && operator* () const &&noexcept
 重载解引用运算符
 
T && operator* () &&noexcept
 重载解引用运算符
 
constexpr operator bool () const noexcept
 bool转换函数
 
constexpr bool hasValue () const noexcept
 判断Dtk::Core::DExpected是否有值
 
const T & value () const &
 获取Dtk::Core::DExpected的期待值
 
T & value () &
 获取Dtk::Core::DExpected的期待值
 
const T && value () const &&
 获取Dtk::Core::DExpected的期待值
 
T && value () &&
 获取Dtk::Core::DExpected的期待值
 
const E & error () const &noexcept
 获取Dtk::Core::DExpected的不期待值
 
E & error () &noexcept
 获取Dtk::Core::DExpected的不期待值
 
const E && error () const &&noexcept
 获取Dtk::Core::DExpected的不期待值
 
E && error () &&noexcept
 获取Dtk::Core::DExpected的不期待值
 
template<typename U >
value_or (U &&_v) const &
 如果有期待值返回期待值,否则返回传入的默认值
 
template<typename U >
value_or (U &&_v) &&
 如果有期待值返回期待值,否则返回传入的默认值
 

友元

template<typename U , typename E2 , typename std::enable_if<!std::is_void< U >::value, bool >::type = true>
bool operator== (const DExpected &_x, const DExpected< U, E2 > &_y) noexcept(noexcept(bool(*_x== *_y)) and noexcept(bool(_x.error()==_y.error())))
 重载相等运算符
 
template<typename U >
constexpr bool operator== (const DExpected &_x, const U &_v) noexcept(noexcept(bool(*_x==_v)))
 重载相等运算符
 
template<typename E2 >
constexpr bool operator== (const DExpected &_x, const DUnexpected< E2 > &_e) noexcept(noexcept(bool(_x.error()==_e.error())))
 重载相等运算符
 
void swap (DExpected &_x, DExpected &_y) noexcept(noexcept(_x.swap(_y)))
 交换两个Dtk::Core::DExpected中的值
 

详细描述

template<typename T, typename E = DError>
class Dtk::Core::DExpected< T, E >

模板类Dtk::Core::DExpected提供存储两个值之一的方式。Dtk::Core::DExpected的对象要么保有一个期待的T类型值,要么保有一个不期待的E类型值,不会没有值。

模板参数
T期待的类型
E不期待的类型
注解
该类自DtkCore 5.6.3引入

构造及析构函数说明

◆ DExpected() [1/14]

template<typename T , typename E = DError>
template<typename U , typename G , typename std::enable_if< std::is_constructible< T, const U & >::value and std::is_constructible< E, const G & >::value and !__cons_from_DExpected< U, G >() and !__explicit_conv< const U &, const G & >(), bool >::type = true>
Dtk::Core::DExpected< T, E >::DExpected ( const DExpected< U, G > &  _x)
inlinenoexcept

Dtk::Core::DExpected的拷贝构造函数

模板参数
U另一个Dtk::Core::DExpected的期待类型
G另一个Dtk::Core::DExpected的不期待类型
参数
[in]_x模板类型分别为U和G的Dtk::Core::DExpected对象

◆ DExpected() [2/14]

template<typename T , typename E = DError>
template<typename U , typename G , typename std::enable_if< std::is_constructible< T, const U & >::value and std::is_constructible< E, const G & >::value and !__cons_from_DExpected< U, G >() and __explicit_conv< const U &, const G & >(), bool >::type = true>
Dtk::Core::DExpected< T, E >::DExpected ( const DExpected< U, G > &  _x)
inlineexplicitnoexcept

Dtk::Core::DExpected的拷贝构造函数

模板参数
U另一个Dtk::Core::DExpected的期待类型
G另一个Dtk::Core::DExpected的不期待类型
参数
[in]_x模板类型分别为U和G的Dtk::Core::DExpected对象
注意
该拷贝构造函数有explicit标识

◆ DExpected() [3/14]

template<typename T , typename E = DError>
template<typename U , typename G , typename std::enable_if< std::is_constructible< T, U >::value and std::is_constructible< E, G >::value and !__cons_from_DExpected< U, G >() and !__explicit_conv< U, G >(), bool >::type = true>
Dtk::Core::DExpected< T, E >::DExpected ( DExpected< U, G > &&  _x)
inlinenoexcept

Dtk::Core::DExpected的移动构造函数

模板参数
U另一个Dtk::Core::DExpected的期待类型
G另一个Dtk::Core::DExpected的不期待类型
参数
[in]_x模板类型分别为U和G的Dtk::Core::DExpected对象
注意
构造后另一个Dtk::Core::DExpected不可用

◆ DExpected() [4/14]

template<typename T , typename E = DError>
template<typename U , typename G , typename std::enable_if< std::is_constructible< T, U >::value and std::is_constructible< E, G >::value and !__cons_from_DExpected< U, G >() and __explicit_conv< U, G >(), bool >::type = true>
Dtk::Core::DExpected< T, E >::DExpected ( DExpected< U, G > &&  _x)
inlineexplicitnoexcept

Dtk::Core::DExpected的移动构造函数

模板参数
U另一个Dtk::Core::DExpected的期待类型
G另一个Dtk::Core::DExpected的不期待类型
参数
[in]_x模板类型分别为U和G的Dtk::Core::DExpected对象
注意
构造后另一个Dtk::Core::DExpected不可用,该函数有explicit标识

◆ DExpected() [5/14]

template<typename T , typename E = DError>
template<typename U = T, typename std::enable_if<!std::is_same< typename remove_cvref< U >::type, DExpected >::value and !std::is_same< typename remove_cvref< U >::type, emplace_tag >::value and !__dexpected::_is_dunexpected< typename remove_cvref< U >::type >::value and std::is_constructible< T, U >::value and !std::is_convertible< U, T >::value, bool >::type = true>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( U &&  _v)
inlineexplicitconstexprnoexcept

Dtk::Core::DExpected的移动构造函数,直接从期待类型构造出Dtk::Core::DExpected对象

模板参数
UDtk::Core::DExpected的期待类型,默认为类型T
参数
[in]_v期待类型为U的对象
注意
构造后原对象不可用,该函数有explicit标识

◆ DExpected() [6/14]

template<typename T , typename E = DError>
template<typename U = T, typename std::enable_if<!std::is_same< typename remove_cvref< U >::type, DExpected >::value and !std::is_same< typename remove_cvref< U >::type, emplace_tag >::value and !__dexpected::_is_dunexpected< typename remove_cvref< U >::type >::value and std::is_constructible< T, U >::value and std::is_convertible< U, T >::value, bool >::type = true>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( U &&  _v)
inlineconstexprnoexcept

Dtk::Core::DExpected的移动构造函数,直接从期待类型构造出Dtk::Core::DExpected对象

模板参数
UDtk::Core::DExpected的期待类型,默认为类型T
参数
[in]_v期待类型为U的对象
注意
构造后原对象不可用

◆ DExpected() [7/14]

template<typename T , typename E = DError>
template<typename G = E, typename std::enable_if< std::is_constructible< E, const G & >::value and !std::is_convertible< const G &, E >::value, bool >::type = true>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( const DUnexpected< G > &  _u)
inlineexplicitconstexprnoexcept

Dtk::Core::DExpected的拷贝构造函数,从Dtk::Core::DUnexpected构造出Dtk::Core::DExpected对象

模板参数
GDtk::Core::DExpected的期待类型,默认为类型E
参数
[in]_u期待类型为G的Dtk::Core::DUnexpected对象
注意
该函数有explicit标识

◆ DExpected() [8/14]

template<typename T , typename E = DError>
template<typename G = E, typename std::enable_if< std::is_constructible< E, const G & >::value and std::is_convertible< const G &, E >::value, bool >::type = true>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( const DUnexpected< G > &  _u)
inlineconstexprnoexcept

Dtk::Core::DExpected的拷贝构造函数,从Dtk::Core::DUnexpected构造出Dtk::Core::DExpected对象

模板参数
GDtk::Core::DExpected的期待类型,默认为类型E
参数
[in]_u期待类型为G的Dtk::Core::DUnexpected对象

◆ DExpected() [9/14]

template<typename T , typename E = DError>
template<typename G = E, typename std::enable_if< std::is_constructible< E, G >::value and !std::is_convertible< G, E >::value, bool >::type = true>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( DUnexpected< G > &&  _u)
inlineexplicitconstexprnoexcept

Dtk::Core::DExpected的移动构造函数,从Dtk::Core::DUnexpected构造出Dtk::Core::DExpected对象

模板参数
GDtk::Core::DExpected的期待类型,默认为类型E
参数
[in]_u期待类型为G的Dtk::Core::DUnexpected对象
注意
构造后原对象不可用,该函数有explicit标识

◆ DExpected() [10/14]

template<typename T , typename E = DError>
template<typename G = E, typename std::enable_if< std::is_constructible< E, G >::value and std::is_convertible< G, E >::value, bool >::type = true>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( DUnexpected< G > &&  _u)
inlineconstexprnoexcept

Dtk::Core::DExpected的移动构造函数,从Dtk::Core::DUnexpected构造出Dtk::Core::DExpected对象

模板参数
GDtk::Core::DExpected的期待类型,默认为类型E
参数
[in]_u期待类型为G的Dtk::Core::DUnexpected对象
注意
构造后原对象不可用

◆ DExpected() [11/14]

template<typename T , typename E = DError>
template<typename... Args>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( emplace_tag  ,
Args &&...  args 
)
inlineexplicitconstexprnoexcept

Dtk::Core::DExpected的转发构造函数,从参数直接构造出期待值

模板参数
Args构造期待类型T所用到的参数的类型
参数
[in]args构造期待类型T所用到的参数
注意
为了区分是构造T还是Dtk::Core::DExpected,需要在第一个参数使用emplace_tag进行标识

◆ DExpected() [12/14]

template<typename T , typename E = DError>
template<typename U , typename... Args>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( emplace_tag  ,
std::initializer_list< U >  _li,
Args &&...  args 
)
inlineexplicitconstexprnoexcept

Dtk::Core::DExpected的转发构造函数,从参数直接构造出期待值

模板参数
U初始化列表的模板参数
Args构造期待类型T所用到的参数的类型
参数
[in]_li构造期待类型T所用到的初始化列表
[in]args构造期待类型T所用到的参数
注意
为了区分是构造T还是Dtk::Core::DExpected,需要在第一个参数使用emplace_tag进行标识

◆ DExpected() [13/14]

template<typename T , typename E = DError>
template<typename... Args>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( dunexpected_tag  ,
Args &&...  args 
)
inlineexplicitconstexprnoexcept

Dtk::Core::DExpected的转发构造函数,从参数直接构造出不期待值

模板参数
Args构造不期待类型E所用到的参数的类型
参数
[in]args构造不期待类型E所用到的参数
注意
为了区分是构造E还是Dtk::Core::DExpected,需要在第一个参数使用dunexpected_tag进行标识

◆ DExpected() [14/14]

template<typename T , typename E = DError>
template<typename U , typename... Args>
constexpr Dtk::Core::DExpected< T, E >::DExpected ( dunexpected_tag  ,
std::initializer_list< U >  _li,
Args &&...  args 
)
inlineexplicitconstexprnoexcept

Dtk::Core::DExpected的转发构造函数,从参数直接构造出不期待值

模板参数
U初始化列表的模板参数
Args构造不期待类型E所用到的参数的类型
参数
[in]_li构造不期待类型E所用到的初始化列表
[in]args构造不期待类型E所用到的参数
注意
为了区分是构造E还是Dtk::Core::DExpected,需要在第一个参数使用dunexpected_tag进行标识

成员函数说明

◆ emplace() [1/2]

template<typename T , typename E = DError>
template<typename... Args>
T & Dtk::Core::DExpected< T, E >::emplace ( Args &&...  args)
inlinenoexcept

从参数直接转发构造期待值

模板参数
Args构造期待值所用到的参数的类型
参数
[in]args构造期待值所用到的参数
返回
返回构造好的期待值的引用

◆ emplace() [2/2]

template<typename T , typename E = DError>
template<typename U , typename... Args>
T & Dtk::Core::DExpected< T, E >::emplace ( std::initializer_list< U >  li,
Args &&...  args 
)
inlinenoexcept

从参数直接转发构造期待值

模板参数
U初始化列表的模板参数
Args构造期待值所用到的参数的类型
参数
[in]args构造期待值所用到的参数
[in]li构造期待值所用到的参数化列表
返回
返回构造好的期待值的引用

◆ error() [1/4]

template<typename T , typename E = DError>
E && Dtk::Core::DExpected< T, E >::error ( ) &&
inlinenoexcept

获取Dtk::Core::DExpected的不期待值

返回
不期待值的右值引用
注意
调用后不期待值不可用

◆ error() [2/4]

template<typename T , typename E = DError>
E & Dtk::Core::DExpected< T, E >::error ( ) &
inlinenoexcept

获取Dtk::Core::DExpected的不期待值

返回
不期待值的左值引用

◆ error() [3/4]

template<typename T , typename E = DError>
const E && Dtk::Core::DExpected< T, E >::error ( ) const &&
inlinenoexcept

获取Dtk::Core::DExpected的不期待值

返回
不期待值的const右值引用
注意
调用后不期待值不可用

◆ error() [4/4]

template<typename T , typename E = DError>
const E & Dtk::Core::DExpected< T, E >::error ( ) const &
inlinenoexcept

获取Dtk::Core::DExpected的不期待值

返回
不期待值的const左值引用

◆ hasValue()

template<typename T , typename E = DError>
constexpr bool Dtk::Core::DExpected< T, E >::hasValue ( ) const
inlineconstexprnoexcept

判断Dtk::Core::DExpected是否有值

返回
表示是否有值的bool值

◆ operator bool()

template<typename T , typename E = DError>
constexpr Dtk::Core::DExpected< T, E >::operator bool ( ) const
inlineexplicitconstexprnoexcept

bool转换函数

返回
表示Dtk::Core::DExpected是否有值的bool值

◆ operator*() [1/4]

template<typename T , typename E = DError>
T && Dtk::Core::DExpected< T, E >::operator* ( ) &&
inlinenoexcept

重载解引用运算符

返回
一个期待值的右值引用

◆ operator*() [2/4]

template<typename T , typename E = DError>
T & Dtk::Core::DExpected< T, E >::operator* ( ) &
inlinenoexcept

重载解引用运算符

返回
一个期待值的左值引用

◆ operator*() [3/4]

template<typename T , typename E = DError>
const T && Dtk::Core::DExpected< T, E >::operator* ( ) const &&
inlinenoexcept

重载解引用运算符

返回
一个期待值的const右值引用

◆ operator*() [4/4]

template<typename T , typename E = DError>
const T & Dtk::Core::DExpected< T, E >::operator* ( ) const &
inlinenoexcept

重载解引用运算符

返回
一个期待值的const左值引用

◆ operator->() [1/2]

template<typename T , typename E = DError>
const T * Dtk::Core::DExpected< T, E >::operator-> ( ) const
inlinenoexcept

重载箭头运算符

返回
一个指向期待值的const指针

◆ operator->() [2/2]

template<typename T , typename E = DError>
T * Dtk::Core::DExpected< T, E >::operator-> ( )
inlinenoexcept

重载箭头运算符

返回
一个指向期待值的指针

◆ operator=() [1/5]

template<typename T , typename E = DError>
template<typename std::enable_if< std::is_copy_assignable< T >::value and std::is_copy_constructible< T >::value and std::is_copy_assignable< E >::value and std::is_copy_constructible< E >::value and(std::is_nothrow_move_constructible< T >::value or std::is_nothrow_move_constructible< E >::value), bool >::type = true>
DExpected & Dtk::Core::DExpected< T, E >::operator= ( const DExpected< T, E > &  _x)
inlinenoexcept

Dtk::Core::DExpected的拷贝赋值运算符

参数
[in]_x同类型的Dtk::Core::DExpected对象

◆ operator=() [2/5]

template<typename T , typename E = DError>
template<typename G , typename std::enable_if< std::is_constructible< E, const G & >::value and std::is_assignable< E &, const G & >::value and(std::is_nothrow_constructible< E, const G & >::value or std::is_nothrow_move_constructible< T >::value or std::is_move_constructible< E >::value), bool >::type = true>
DExpected & Dtk::Core::DExpected< T, E >::operator= ( const DUnexpected< G > &  _e)
inline

Dtk::Core::DExpected的拷贝赋值运算符

模板参数
G不期待类型
参数
[in]_e模板类型为G的Dtk::Core::DUnexpected对象

◆ operator=() [3/5]

template<typename T , typename E = DError>
template<typename std::enable_if< std::is_move_assignable< T >::value and std::is_move_constructible< T >::value and std::is_move_assignable< E >::value and std::is_move_constructible< E >::value and(std::is_nothrow_move_constructible< T >::value or std::is_nothrow_move_constructible< E >::value), bool >::type = true>
DExpected & Dtk::Core::DExpected< T, E >::operator= ( DExpected< T, E > &&  _x)
inlinenoexcept

Dtk::Core::DExpected的移动赋值运算符

参数
[in]_x同类型的Dtk::Core::DExpected对象
注意
赋值后原对象不可用

◆ operator=() [4/5]

template<typename T , typename E = DError>
template<typename G , typename std::enable_if< std::is_constructible< E, G >::value and std::is_assignable< E &, G >::value and(std::is_nothrow_constructible< E, G >::value or std::is_nothrow_move_constructible< T >::value or std::is_move_constructible< E >::value), bool >::type = true>
DExpected & Dtk::Core::DExpected< T, E >::operator= ( DUnexpected< G > &&  _e)
inline

Dtk::Core::DExpected的移动赋值运算符

模板参数
G不期待类型
参数
[in]_e模板类型为G的Dtk::Core::DUnexpected对象
注意
赋值后原对象不可用

◆ operator=() [5/5]

template<typename T , typename E = DError>
template<typename U = T, typename std::enable_if<!std::is_same< DExpected, typename remove_cvref< U >::type >::value and !__dexpected::_is_dunexpected< typename remove_cvref< U >::type >::value and std::is_constructible< T, U >::value and std::is_assignable< T &, U >::value and(std::is_nothrow_constructible< T, U >::value or std::is_nothrow_move_constructible< T >::value or std::is_nothrow_move_constructible< E >::value), bool >::type = true>
DExpected & Dtk::Core::DExpected< T, E >::operator= ( U &&  _v)
inline

Dtk::Core::DExpected的转发赋值运算符

模板参数
U期待类型,默认为T
参数
[in]_v期待类型U的对象

◆ swap()

template<typename T , typename E = DError>
template<typename std::enable_if< std::is_move_constructible< T >::value and std::is_move_constructible< E >::value and(std::is_nothrow_move_constructible< T >::value or std::is_nothrow_move_constructible< E >::value), bool >::type = true>
void Dtk::Core::DExpected< T, E >::swap ( DExpected< T, E > &  _x)
inlinenoexcept

交换两个Dtk::Core::DExpected的值

参数
[in]_x另一个Dtk::Core::DExpected对象

◆ value() [1/4]

template<typename T , typename E = DError>
T & Dtk::Core::DExpected< T, E >::value ( ) &
inline

获取Dtk::Core::DExpected的期待值

返回
期待值的左值引用

◆ value() [2/4]

template<typename T , typename E = DError>
T && Dtk::Core::DExpected< T, E >::value ( ) &&
inline

获取Dtk::Core::DExpected的期待值

返回
期待值的右值引用
注意
调用后期待值不可用

◆ value() [3/4]

template<typename T , typename E = DError>
const T & Dtk::Core::DExpected< T, E >::value ( ) const &
inline

获取Dtk::Core::DExpected的期待值

返回
期待值的const左值引用

◆ value() [4/4]

template<typename T , typename E = DError>
const T && Dtk::Core::DExpected< T, E >::value ( ) const &&
inline

获取Dtk::Core::DExpected的期待值

返回
期待值的const右值引用
注意
调用后期待值不可用

◆ value_or() [1/2]

template<typename T , typename E = DError>
template<typename U >
T Dtk::Core::DExpected< T, E >::value_or ( U &&  _v) &&
inline

如果有期待值返回期待值,否则返回传入的默认值

模板参数
U期待值的类型
参数
[in]_v默认的期待值
返回
期待值
注意
如果由期待值,调用后原期待值不可用,同时类型U要可以转换成类型T

◆ value_or() [2/2]

template<typename T , typename E = DError>
template<typename U >
T Dtk::Core::DExpected< T, E >::value_or ( U &&  _v) const &
inline

如果有期待值返回期待值,否则返回传入的默认值

模板参数
U期待值的类型
参数
[in]_v默认的期待值
返回
期待值

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