模板类Dtk::Core::DExpected提供存储两个值之一的方式。Dtk::Core::DExpected的对象要么保有一个期待的T类型值,要么保有一个不期待的E类型值,不会没有值。
更多...
|
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的析构函数
|
|
DExpected & | operator= (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> |
DExpected & | operator= (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> |
DExpected & | operator= (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> |
DExpected & | operator= (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> |
DExpected & | operator= (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> |
DExpected & | operator= (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 > |
T | value_or (U &&_v) const & |
| 如果有期待值返回期待值,否则返回传入的默认值
|
|
template<typename U > |
T | value_or (U &&_v) && |
| 如果有期待值返回期待值,否则返回传入的默认值
|
|
template<typename T, typename E = DError>
class Dtk::Core::DExpected< T, E >
模板类Dtk::Core::DExpected提供存储两个值之一的方式。Dtk::Core::DExpected的对象要么保有一个期待的T类型值,要么保有一个不期待的E类型值,不会没有值。
- 模板参数
-
- 注解
- 该类自DtkCore 5.6.3引入