|
| optional () |
| constructs an object that does not contain a value.
|
|
| optional (dmlc::nullopt_t) noexcept |
| constructs an object that does contain a nullopt value.
|
|
| optional (const optional< T > &other) |
| construct an optional object with another optional object
|
|
| optional (optional &&other) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value) |
| move constructor: If other contains a value, then stored value is direct-intialized with it.
|
|
template<typename... Args> |
| optional (enable_if_t< std::is_constructible< T, Args... >::value, in_place_t >, Args &&...args) |
| constructs an optional object that contains a value, initialized as if direct-initializing
|
|
template<typename U , typename... Args> |
| optional (enable_if_t< std::is_constructible< T, std::initializer_list< U > &, Args &&... >::value, in_place_t >, std::initializer_list< U > ilist, Args &&...args) |
| Constructs an optional object that contains a value, initialized as if direct-initializing.
|
|
template<typename U = value_type, enable_if_t< std::is_convertible< U &&, T >::value > * = nullptr, enable_constructor_from_value< T, U > * = nullptr> |
| optional (U &&other) noexcept |
| constructs the stored value with value with other parameter.
|
|
template<typename U = value_type, enable_if_t<!std::is_convertible< U &&, T >::value > * = nullptr, enable_constructor_from_value< T, U > * = nullptr> |
| optional (U &&other) noexcept |
| explicit constructor: constructs the stored value with other parameter.
|
|
template<typename U , enable_constructor_from_other< T, U, const U & > * = nullptr, enable_if_t< std::is_convertible< const U &, T >::value > * = nullptr> |
| optional (const optional< U > &other) |
| converting copy constructor
|
|
template<typename U , enable_constructor_from_other< T, U, const U & > * = nullptr, enable_if_t<!std::is_convertible< const U &, T >::value > * = nullptr> |
| optional (const optional< U > &other) |
| explicit converting copy constructor
|
|
template<typename U , enable_constructor_from_other< T, U, U && > * = nullptr, enable_if_t< std::is_convertible< U &&, T >::value > * = nullptr> |
| optional (optional< U > &&other) |
| converting move constructor
|
|
template<typename U , enable_constructor_from_other< T, U, U && > * = nullptr, enable_if_t<!std::is_convertible< U &&, T >::value > * = nullptr> |
| optional (optional< U > &&other) |
| explicit converting move constructor
|
|
void | reset () noexcept |
| reset
|
|
| ~optional () |
| deconstructor
|
|
void | swap (optional< T > &other) |
| swap two optional
|
|
optional< T > & | operator= (const T &value) |
| set this object to hold value
|
|
optional< T > & | operator= (const optional< T > &other) |
| set this object to hold the same value with other
|
|
optional< T > & | operator= (nullopt_t) |
| clear the value this object is holding. optional<T> x = nullopt;
|
|
T & | operator* () |
| non-const dereference operator
|
|
const T & | operator* () const |
| const dereference operator
|
|
bool | operator== (const optional< T > &other) const |
| equal comparison
|
|
T & | value () & |
| return the holded value. throws std::logic_error if holding no value
|
|
const T & | value () const & |
|
T && | value () && |
|
const T && | value () const && |
|
| operator bool () const |
| whether this object is holding a value
|
|
bool | has_value () const |
| whether this object is holding a value (alternate form).
|
|
template<typename T>
class dmlc::optional< T >
Is not constructible or convertible from any expression of type (possibly const) dmlc::optional<U>, i.e., the following 8 type traits are all false: Link: https://en.cppreference.com/w/cpp/utility/optional/optional.
c++17 compatible optional class.
At any time an optional<T> instance either hold no value (string representation "None") or hold a value of type T.