tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches

etl::optional class template More...

Classes

struct  bad_optional_access
 Defines a type of object to be thrown by etl::optional::value when accessing an optional object that does not contain a value. More...
 
struct  hash< etl::optional< T > >
 The template specialization of etl::hash for the etl::optional class allows users to obtain hashes of the values contained in optional objects. More...
 
struct  nullopt_t
 etl::nullopt_t is an empty class type used to indicate optional type with uninitialized state. In particular, etl::optional has a constructor with nullopt_t as a single argument, which creates an optional that does not contain a value. More...
 
struct  optional< T >
 The class template optional manages an optional contained value, i.e. a value that may or may not be present. More...
 

Functions

template<typename T>
 optional (T) -> optional< T >
 
template<typename T, typename... Args>
constexpr auto make_optional (Args &&... args) -> etl::optional< T >
 Creates an optional object constructed in-place from args...
 
template<typename T>
constexpr auto make_optional (T &&value) -> etl::optional< etl::decay_t< T > >
 Creates an optional object from value.
 
template<typename T>
constexpr auto operator< (etl::nullopt_t, optional< T > const &opt) noexcept -> bool
 Compares opt with a nullopt.
 
template<typename T>
constexpr auto operator< (optional< T > const &, etl::nullopt_t) noexcept -> bool
 Compares opt with a nullopt.
 
template<typename T, typename U>
constexpr auto operator< (optional< T > const &lhs, optional< U > const &rhs) -> bool
 Compares two optional objects, lhs and rhs.
 
template<typename T, typename U>
constexpr auto operator< (optional< T > const &opt, U const &value) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 
template<typename T, typename U>
constexpr auto operator< (T const &value, optional< U > const &opt) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 
template<typename T, typename U>
constexpr auto operator<= (optional< T > const &lhs, optional< U > const &rhs) -> bool
 Compares two optional objects, lhs and rhs.
 
template<typename T, typename U>
constexpr auto operator<= (optional< T > const &opt, U const &value) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 
template<typename T, typename U>
constexpr auto operator<= (T const &value, optional< U > const &opt) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 
template<typename T>
constexpr auto operator== (etl::nullopt_t, optional< T > const &opt) noexcept -> bool
 Compares opt with a nullopt.
 
template<typename T, typename U>
constexpr auto operator== (optional< T > const &lhs, optional< U > const &rhs) -> bool
 Compares two optional objects, lhs and rhs.
 
template<typename T>
constexpr auto operator== (optional< T > const &opt, etl::nullopt_t) noexcept -> bool
 Compares opt with a nullopt.
 
template<typename T, typename U>
constexpr auto operator== (optional< T > const &opt, U const &value) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 
template<typename T, typename U>
constexpr auto operator> (optional< T > const &lhs, optional< U > const &rhs) -> bool
 Compares two optional objects, lhs and rhs.
 
template<typename T, typename U>
constexpr auto operator> (optional< T > const &opt, U const &value) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 
template<typename T, typename U>
constexpr auto operator> (T const &value, optional< U > const &opt) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 
template<typename T, typename U>
constexpr auto operator>= (optional< T > const &lhs, optional< U > const &rhs) -> bool
 Compares two optional objects, lhs and rhs.
 
template<typename T, typename U>
constexpr auto operator>= (optional< T > const &opt, U const &value) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 
template<typename T, typename U>
constexpr auto operator>= (T const &value, optional< U > const &opt) -> bool
 Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.
 

Variables

constexpr auto nullopt = etl::nullopt_t{0}
 etl::nullopt is a constant of type etl::nullopt_t that is used to indicate optional type with uninitialized state.
 

Detailed Description

etl::optional class template

Function Documentation

◆ optional()

template<typename T>
optional ( T ) -> optional< T >
related

◆ make_optional() [1/2]

template<typename T, typename... Args>
auto make_optional ( Args &&... args) -> etl::optional<T>
related

Creates an optional object constructed in-place from args...

◆ make_optional() [2/2]

template<typename T>
auto make_optional ( T && value) -> etl::optional<etl::decay_t<T>>
related

Creates an optional object from value.

◆ operator<() [1/5]

template<typename T>
auto operator< ( etl::nullopt_t ,
optional< T > const & opt ) -> bool
related

Compares opt with a nullopt.

Equivalent to when comparing to an optional that does not contain a value.

◆ operator<() [2/5]

template<typename T>
auto operator< ( optional< T > const & ,
etl::nullopt_t  ) -> bool
related

Compares opt with a nullopt.

Equivalent to when comparing to an optional that does not contain a value.

◆ operator<() [3/5]

template<typename T, typename U>
auto operator< ( optional< T > const & lhs,
optional< U > const & rhs ) -> bool
related

Compares two optional objects, lhs and rhs.

◆ operator<() [4/5]

template<typename T, typename U>
auto operator< ( optional< T > const & opt,
U const & value ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

◆ operator<() [5/5]

template<typename T, typename U>
auto operator< ( T const & value,
optional< U > const & opt ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

◆ operator<=() [1/3]

template<typename T, typename U>
auto operator<= ( optional< T > const & lhs,
optional< U > const & rhs ) -> bool
related

Compares two optional objects, lhs and rhs.

◆ operator<=() [2/3]

template<typename T, typename U>
auto operator<= ( optional< T > const & opt,
U const & value ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

◆ operator<=() [3/3]

template<typename T, typename U>
auto operator<= ( T const & value,
optional< U > const & opt ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

◆ operator==() [1/4]

template<typename T>
auto operator== ( etl::nullopt_t ,
optional< T > const & opt ) -> bool
related

Compares opt with a nullopt.

Equivalent to when comparing to an optional that does not contain a value.

◆ operator==() [2/4]

template<typename T, typename U>
auto operator== ( optional< T > const & lhs,
optional< U > const & rhs ) -> bool
related

Compares two optional objects, lhs and rhs.

◆ operator==() [3/4]

template<typename T>
auto operator== ( optional< T > const & opt,
etl::nullopt_t  ) -> bool
related

Compares opt with a nullopt.

Equivalent to when comparing to an optional that does not contain a value.

◆ operator==() [4/4]

template<typename T, typename U>
auto operator== ( optional< T > const & opt,
U const & value ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

◆ operator>() [1/3]

template<typename T, typename U>
auto operator> ( optional< T > const & lhs,
optional< U > const & rhs ) -> bool
related

Compares two optional objects, lhs and rhs.

◆ operator>() [2/3]

template<typename T, typename U>
auto operator> ( optional< T > const & opt,
U const & value ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

◆ operator>() [3/3]

template<typename T, typename U>
auto operator> ( T const & value,
optional< U > const & opt ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

◆ operator>=() [1/3]

template<typename T, typename U>
auto operator>= ( optional< T > const & lhs,
optional< U > const & rhs ) -> bool
related

Compares two optional objects, lhs and rhs.

◆ operator>=() [2/3]

template<typename T, typename U>
auto operator>= ( optional< T > const & opt,
U const & value ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

◆ operator>=() [3/3]

template<typename T, typename U>
auto operator>= ( T const & value,
optional< U > const & opt ) -> bool
related

Compares opt with a value. The values are compared (using the corresponding operator of T) only if opt contains a value. Otherwise, opt is considered less than value. If the corresponding two-way comparison expression between *opt and value is not well-formed, or if its result is not convertible to bool, the program is ill-formed.

https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

Variable Documentation

◆ nullopt

auto nullopt = etl::nullopt_t{0}
related

etl::nullopt is a constant of type etl::nullopt_t that is used to indicate optional type with uninitialized state.