Public Types | Public Member Functions | Public Attributes | Private Types | List of all members
sol::optional< T > Class Template Reference

#include <forward.hpp>

Inheritance diagram for sol::optional< T >:
Inheritance graph
[legend]

Public Types

using value_type = T
 

Public Member Functions

template<class F >
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then (F &&f) &
 
template<class F >
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T && > and_then (F &&f) &&
 
template<class F >
constexpr detail::invoke_result_t< F, const T & > and_then (F &&f) const &
 
template<class F >
constexpr detail::invoke_result_t< F, const T && > and_then (F &&f) const &&
 
template<class U >
constexpr optional< typename std::decay< U >::typeconjunction (U &&u) const
 
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction (const optional &rhs) &
 
constexpr optional disjunction (const optional &rhs) const &
 disjunction More...
 
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction (const optional &rhs) &&
 disjunction More...
 
constexpr optional disjunction (const optional &rhs) const &&
 disjunction More...
 
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction (optional &&rhs) &
 disjunction More...
 
constexpr optional disjunction (optional &&rhs) const &
 disjunction More...
 
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction (optional &&rhs) &&
 disjunction More...
 
constexpr optional disjunction (optional &&rhs) const &&
 disjunction More...
 
template<class... Args>
T & emplace (Args &&... args)
 
template<class U , class... Args>
detail::enable_if_t< std::is_constructible< T, std::initializer_list< U > &, Args &&... >::value, T & > emplace (std::initializer_list< U > il, Args &&... args)
 
constexpr bool has_value () const noexcept
 
template<class F , class U >
map_or (F &&f, U &&u) &
 Maps the stored value with f if there is one, otherwise returns u. More...
 
template<class F , class U >
map_or (F &&f, U &&u) &&
 map_or More...
 
template<class F , class U >
map_or (F &&f, U &&u) const &
 map_or More...
 
template<class F , class U >
map_or (F &&f, U &&u) const &&
 map_or More...
 
template<class F , class U >
detail::invoke_result_t< U > map_or_else (F &&f, U &&u) &
 Maps the stored value with f if there is one, otherwise calls u and returns the result. More...
 
template<class F , class U >
detail::invoke_result_t< U > map_or_else (F &&f, U &&u) &&
 
template<class F , class U >
detail::invoke_result_t< U > map_or_else (F &&f, U &&u) const &
 
template<class F , class U >
detail::invoke_result_t< U > map_or_else (F &&f, U &&u) const &&
 
constexpr operator bool () const noexcept
 has_value More...
 
SOL_TL_OPTIONAL_11_CONSTEXPR T & operator* () &
 
constexpr const T & operator* () const &
 
SOL_TL_OPTIONAL_11_CONSTEXPR T && operator* () &&
 
constexpr const T && operator* () const &&
 
constexpr const T * operator-> () const
 
SOL_TL_OPTIONAL_11_CONSTEXPR T * operator-> ()
 
optionaloperator= (nullopt_t) noexcept
 
optionaloperator= (const optional &rhs)=default
 
optionaloperator= (optional &&rhs)=default
 
template<class U = T, detail::enable_assign_forward< T, U > * = nullptr>
optionaloperator= (U &&u)
 
template<class U , detail::enable_assign_from_other< T, U, const U &> * = nullptr>
optionaloperator= (const optional< U > &rhs)
 
template<class U , detail::enable_assign_from_other< T, U, U > * = nullptr>
optionaloperator= (optional< U > &&rhs)
 
constexpr optional () noexcept=default
 
constexpr optional (nullopt_t) noexcept
 ctor_empty More...
 
SOL_TL_OPTIONAL_11_CONSTEXPR optional (const optional &rhs)=default
 
SOL_TL_OPTIONAL_11_CONSTEXPR optional (optional &&rhs)=default
 
template<class... Args>
constexpr optional (detail::enable_if_t< std::is_constructible< T, Args... >::value, in_place_t >, Args &&... args)
 
template<class U , class... Args>
SOL_TL_OPTIONAL_11_CONSTEXPR optional (detail::enable_if_t< std::is_constructible< T, std::initializer_list< U > &, Args &&... >::value, in_place_t >, std::initializer_list< U > il, Args &&... args)
 
constexpr optional (T &&u)
 
constexpr optional (const T &u)
 
template<class U , detail::enable_from_other< T, U, const U &> * = nullptr, detail::enable_if_t< std::is_convertible< const U &, T >::value > * = nullptr>
 optional (const optional< U > &rhs)
 
template<class U , detail::enable_from_other< T, U, const U &> * = nullptr, detail::enable_if_t<!std::is_convertible< const U &, T >::value > * = nullptr>
 optional (const optional< U > &rhs)
 
template<class U , detail::enable_from_other< T, U, U &&> * = nullptr, detail::enable_if_t< std::is_convertible< U &&, T >::value > * = nullptr>
 optional (optional< U > &&rhs)
 
template<class U , detail::enable_from_other< T, U, U &&> * = nullptr, detail::enable_if_t<!std::is_convertible< U &&, T >::value > * = nullptr>
 optional (optional< U > &&rhs)
 
template<class F , detail::enable_if_ret_void< F > * = nullptr>
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else (F &&f) &
 Calls f if the optional is empty std::invoke_result_t<F> must be void or convertible to optional<T>. If *this has a value, returns *this. Otherwise, if f returns void, calls std::forward<F>(f) and returns std::nullopt. Otherwise, returns std::forward<F>(f)(). More...
 
template<class F , detail::disable_if_ret_void< F > * = nullptr>
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else (F &&f) &
 
template<class F , detail::enable_if_ret_void< F > * = nullptr>
optional< T > or_else (F &&f) &&
 
template<class F , detail::disable_if_ret_void< F > * = nullptr>
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else (F &&f) &&
 
template<class F , detail::enable_if_ret_void< F > * = nullptr>
optional< T > or_else (F &&f) const &
 
template<class F , detail::disable_if_ret_void< F > * = nullptr>
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else (F &&f) const &
 
template<class F , detail::enable_if_ret_void< F > * = nullptr>
optional< T > or_else (F &&f) const &&
 
template<class F , detail::disable_if_ret_void< F > * = nullptr>
optional< T > or_else (F &&f) const &&
 
void reset () noexcept
 Destroys the stored value if one exists, making the optional empty. More...
 
void swap (optional &rhs) noexcept(std::is_nothrow_move_constructible< T >::value &&detail::is_nothrow_swappable< T >::value)
 
optional take () &
 
optional take () const &
 take More...
 
optional take () &&
 take More...
 
optional take () const &&
 take More...
 
SOL_TL_OPTIONAL_11_CONSTEXPR T & value () &
 
SOL_TL_OPTIONAL_11_CONSTEXPR const T & value () const &
 
SOL_TL_OPTIONAL_11_CONSTEXPR T && value () &&
 
SOL_TL_OPTIONAL_11_CONSTEXPR const T && value () const &&
 
template<class U >
constexpr T value_or (U &&u) const &
 
template<class U >
SOL_TL_OPTIONAL_11_CONSTEXPRvalue_or (U &&u) &&
 value_or More...
 
 ~optional ()=default
 Destroys the stored value if there is one. More...
 

Public Attributes

template<class F >
decltype(optional_map_impl(std::declval< optional & >(), std::declval< F && >())) SOL_TL_OPTIONAL_11_CONSTEXPR map (F &&f) &
 Carries out some operation on the stored object if there is one. More...
 
template<class F >
decltype(optional_map_impl(std::declval< optional && >(), std::declval< F && >())) SOL_TL_OPTIONAL_11_CONSTEXPR map (F &&f) &&
 
template<class F >
decltype(optional_map_impl(std::declval< const optional & >(), std::declval< F && >())) constexpr map (F &&f) const &
 
template<class F >
decltype(optional_map_impl(std::declval< const optional && >(), std::declval< F && >())) constexpr map (F &&f) const &&
 

Private Types

using base = detail::optional_move_assign_base< T >
 

Additional Inherited Members

- Private Member Functions inherited from sol::detail::optional_operations_base< T >
template<class Opt >
void assign (Opt &&rhs)
 
template<class... Args>
void construct (Args &&... args) noexcept
 
SOL_TL_OPTIONAL_11_CONSTEXPR T & get () &
 
SOL_TL_OPTIONAL_11_CONSTEXPR const T & get () const &
 
SOL_TL_OPTIONAL_11_CONSTEXPR T && get () &&
 
constexpr const T && get () const &&
 
void hard_reset () noexcept
 
bool has_value () const
 
- Private Member Functions inherited from sol::detail::optional_storage_base< T >
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base () noexcept
 
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base (in_place_t, U &&... u)
 
 ~optional_storage_base ()
 
- Private Member Functions inherited from sol::detail::optional_delete_ctor_base< T >
optional_delete_ctor_baseoperator= (const optional_delete_ctor_base &)=default
 
optional_delete_ctor_baseoperator= (optional_delete_ctor_base &&) noexcept=default
 
 optional_delete_ctor_base ()=default
 
 optional_delete_ctor_base (const optional_delete_ctor_base &)=default
 
 optional_delete_ctor_base (optional_delete_ctor_base &&) noexcept=default
 
- Private Member Functions inherited from sol::detail::optional_delete_assign_base< T >
optional_delete_assign_baseoperator= (const optional_delete_assign_base &)=default
 
optional_delete_assign_baseoperator= (optional_delete_assign_base &&) noexcept=default
 
 optional_delete_assign_base ()=default
 
 optional_delete_assign_base (const optional_delete_assign_base &)=default
 
 optional_delete_assign_base (optional_delete_assign_base &&) noexcept=default
 
- Private Attributes inherited from sol::detail::optional_storage_base< T >
union {
   dummy   m_dummy
 
   T   m_value
 
}; 
 
dummy m_dummy
 
bool m_has_value
 
m_value
 

Detailed Description

template<class T>
class sol::optional< T >

An optional object is an object that contains the storage for another object and manages the lifetime of this contained object, if any. The contained object may be initialized after the optional object has been initialized, and may be destroyed before the optional object has been destroyed. The initialization state of the contained object is tracked by the optional object.

Definition at line 1291 of file forward.hpp.

Member Typedef Documentation

◆ base

template<class T>
using sol::optional< T >::base = detail::optional_move_assign_base<T>
private

Definition at line 5247 of file sol.hpp.

◆ value_type

template<class T>
using sol::optional< T >::value_type = T

Definition at line 5660 of file sol.hpp.

Constructor & Destructor Documentation

◆ optional() [1/12]

template<class T>
constexpr sol::optional< T >::optional ( )
defaultnoexcept

Constructs an optional that does not contain a value. ctor_empty

◆ optional() [2/12]

template<class T>
constexpr sol::optional< T >::optional ( nullopt_t  )
inlinenoexcept

ctor_empty

Definition at line 5667 of file sol.hpp.

◆ optional() [3/12]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::optional ( const optional< T > &  rhs)
default

Copy constructor

If rhs contains a value, the stored value is direct-initialized with it. Otherwise, the constructed optional is empty.

◆ optional() [4/12]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::optional ( optional< T > &&  rhs)
default

Move constructor

If rhs contains a value, the stored value is direct-initialized with it. Otherwise, the constructed optional is empty.

◆ optional() [5/12]

template<class T>
template<class... Args>
constexpr sol::optional< T >::optional ( detail::enable_if_t< std::is_constructible< T, Args... >::value, in_place_t ,
Args &&...  args 
)
inlineexplicit

Constructs the stored value in-place using the given arguments. in_place template <class... Args> constexpr explicit optional(in_place_t, Args&&... args);

Definition at line 5686 of file sol.hpp.

◆ optional() [6/12]

template<class T>
template<class U , class... Args>
SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::optional ( detail::enable_if_t< std::is_constructible< T, std::initializer_list< U > &, Args &&... >::value, in_place_t ,
std::initializer_list< U >  il,
Args &&...  args 
)
inlineexplicit

in_place template <class U, class... Args>
constexpr explicit optional(in_place_t, std::initializer_list<U>&, Args&&... args);

Definition at line 5693 of file sol.hpp.

◆ optional() [7/12]

template<class T>
constexpr sol::optional< T >::optional ( T &&  u)
inline

Constructs the stored value with u. template <class u="T"> constexpr optional(U &&u);

Definition at line 5712 of file sol.hpp.

◆ optional() [8/12]

template<class T>
constexpr sol::optional< T >::optional ( const T &  u)
inline

Definition at line 5716 of file sol.hpp.

◆ optional() [9/12]

template<class T>
template<class U , detail::enable_from_other< T, U, const U &> * = nullptr, detail::enable_if_t< std::is_convertible< const U &, T >::value > * = nullptr>
sol::optional< T >::optional ( const optional< U > &  rhs)
inline

Converting copy constructor. template <class u>=""> optional(const optional<U> &rhs);

Definition at line 5723 of file sol.hpp.

◆ optional() [10/12]

template<class T>
template<class U , detail::enable_from_other< T, U, const U &> * = nullptr, detail::enable_if_t<!std::is_convertible< const U &, T >::value > * = nullptr>
sol::optional< T >::optional ( const optional< U > &  rhs)
inlineexplicit

Definition at line 5731 of file sol.hpp.

◆ optional() [11/12]

template<class T>
template<class U , detail::enable_from_other< T, U, U &&> * = nullptr, detail::enable_if_t< std::is_convertible< U &&, T >::value > * = nullptr>
sol::optional< T >::optional ( optional< U > &&  rhs)
inline

Converting move constructor. template <class u>=""> optional(optional<U> &&rhs);

Definition at line 5740 of file sol.hpp.

◆ optional() [12/12]

template<class T>
template<class U , detail::enable_from_other< T, U, U &&> * = nullptr, detail::enable_if_t<!std::is_convertible< U &&, T >::value > * = nullptr>
sol::optional< T >::optional ( optional< U > &&  rhs)
inlineexplicit

Definition at line 5748 of file sol.hpp.

◆ ~optional()

template<class T>
sol::optional< T >::~optional ( )
default

Destroys the stored value if there is one.

Member Function Documentation

◆ and_then() [1/4]

template<class T>
template<class F >
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t<F, T&> sol::optional< T >::and_then ( F &&  f) &
inline

and_then Carries out some operation which returns an optional on the stored object if there is one. std::invoke(std::forward<F>(f), value()) returns a std::optional<U> for some U.

Returns
Let U be the result of std::invoke(std::forward<F>(f), value()). Returns a std::optional<U>. The return value is empty if *this is empty, otherwise the return value of std::invoke(std::forward<F>(f), value()) is returned. and_then template <class f>="">
constexpr auto and_then(F &&f) &;

Definition at line 5315 of file sol.hpp.

◆ and_then() [2/4]

template<class T>
template<class F >
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t<F, T&&> sol::optional< T >::and_then ( F &&  f) &&
inline

and_then template <class f>="">
constexpr auto and_then(F &&f) &&;

Definition at line 5325 of file sol.hpp.

◆ and_then() [3/4]

template<class T>
template<class F >
constexpr detail::invoke_result_t<F, const T&> sol::optional< T >::and_then ( F &&  f) const &
inline

and_then template <class f>="">
constexpr auto and_then(F &&f) const &;

Definition at line 5335 of file sol.hpp.

◆ and_then() [4/4]

template<class T>
template<class F >
constexpr detail::invoke_result_t<F, const T&&> sol::optional< T >::and_then ( F &&  f) const &&
inline

and_then template <class f>="">
constexpr auto and_then(F &&f) const &&;

Definition at line 5346 of file sol.hpp.

◆ conjunction()

template<class T>
template<class U >
constexpr optional<typename std::decay<U>::type> sol::optional< T >::conjunction ( U &&  u) const
inline
Returns
u if *this has a value, otherwise an empty optional.

Definition at line 5579 of file sol.hpp.

◆ disjunction() [1/8]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR optional sol::optional< T >::disjunction ( const optional< T > &  rhs) &
inline
Returns
rhs if *this is empty, otherwise the current value. disjunction

Definition at line 5586 of file sol.hpp.

◆ disjunction() [2/8]

template<class T>
constexpr optional sol::optional< T >::disjunction ( const optional< T > &  rhs) const &
inline

disjunction

Definition at line 5591 of file sol.hpp.

◆ disjunction() [3/8]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR optional sol::optional< T >::disjunction ( const optional< T > &  rhs) &&
inline

disjunction

Definition at line 5596 of file sol.hpp.

◆ disjunction() [4/8]

template<class T>
constexpr optional sol::optional< T >::disjunction ( const optional< T > &  rhs) const &&
inline

disjunction

Definition at line 5602 of file sol.hpp.

◆ disjunction() [5/8]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR optional sol::optional< T >::disjunction ( optional< T > &&  rhs) &
inline

disjunction

Definition at line 5608 of file sol.hpp.

◆ disjunction() [6/8]

template<class T>
constexpr optional sol::optional< T >::disjunction ( optional< T > &&  rhs) const &
inline

disjunction

Definition at line 5613 of file sol.hpp.

◆ disjunction() [7/8]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR optional sol::optional< T >::disjunction ( optional< T > &&  rhs) &&
inline

disjunction

Definition at line 5618 of file sol.hpp.

◆ disjunction() [8/8]

template<class T>
constexpr optional sol::optional< T >::disjunction ( optional< T > &&  rhs) const &&
inline

disjunction

Definition at line 5624 of file sol.hpp.

◆ emplace() [1/2]

template<class T>
template<class... Args>
T& sol::optional< T >::emplace ( Args &&...  args)
inline

Constructs the value in-place, destroying the current one if there is one. emplace

Definition at line 5845 of file sol.hpp.

◆ emplace() [2/2]

template<class T>
template<class U , class... Args>
detail::enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value, T&> sol::optional< T >::emplace ( std::initializer_list< U >  il,
Args &&...  args 
)
inline

emplace template <class U, class... Args>
T& emplace(std::initializer_list<U> il, Args &&... args);

Definition at line 5856 of file sol.hpp.

◆ has_value()

template<class T>
constexpr bool sol::optional< T >::has_value ( ) const
inlinenoexcept
Returns
whether or not the optional has a value has_value

Definition at line 5927 of file sol.hpp.

◆ map_or() [1/4]

template<class T>
template<class F , class U >
U sol::optional< T >::map_or ( F &&  f,
U &&  u 
) &
inline

Maps the stored value with f if there is one, otherwise returns u.

If there is a value stored, then f is called with **this and the value is returned. Otherwise u is returned.

map_or

Definition at line 5513 of file sol.hpp.

◆ map_or() [2/4]

template<class T>
template<class F , class U >
U sol::optional< T >::map_or ( F &&  f,
U &&  u 
) &&
inline

map_or

Definition at line 5519 of file sol.hpp.

◆ map_or() [3/4]

template<class T>
template<class F , class U >
U sol::optional< T >::map_or ( F &&  f,
U &&  u 
) const &
inline

map_or

Definition at line 5525 of file sol.hpp.

◆ map_or() [4/4]

template<class T>
template<class F , class U >
U sol::optional< T >::map_or ( F &&  f,
U &&  u 
) const &&
inline

map_or

Definition at line 5532 of file sol.hpp.

◆ map_or_else() [1/4]

template<class T>
template<class F , class U >
detail::invoke_result_t<U> sol::optional< T >::map_or_else ( F &&  f,
U &&  u 
) &
inline

Maps the stored value with f if there is one, otherwise calls u and returns the result.

If there is a value stored, then f is called with **this and the value is returned. Otherwise std::forward<U>(u)() is returned.

map_or_else template <class F, class U>
auto map_or_else(F &&f, U &&u) &;

Definition at line 5547 of file sol.hpp.

◆ map_or_else() [2/4]

template<class T>
template<class F , class U >
detail::invoke_result_t<U> sol::optional< T >::map_or_else ( F &&  f,
U &&  u 
) &&
inline

map_or_else template <class F, class U>
auto map_or_else(F &&f, U &&u) &&;

Definition at line 5555 of file sol.hpp.

◆ map_or_else() [3/4]

template<class T>
template<class F , class U >
detail::invoke_result_t<U> sol::optional< T >::map_or_else ( F &&  f,
U &&  u 
) const &
inline

map_or_else template <class F, class U>
auto map_or_else(F &&f, U &&u) const &;

Definition at line 5563 of file sol.hpp.

◆ map_or_else() [4/4]

template<class T>
template<class F , class U >
detail::invoke_result_t<U> sol::optional< T >::map_or_else ( F &&  f,
U &&  u 
) const &&
inline

map_or_else template <class F, class U>
auto map_or_else(F &&f, U &&u) const &&;

Definition at line 5572 of file sol.hpp.

◆ operator bool()

template<class T>
constexpr sol::optional< T >::operator bool ( ) const
inlineexplicitnoexcept

has_value

Definition at line 5932 of file sol.hpp.

◆ operator*() [1/4]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR T& sol::optional< T >::operator* ( ) &
inline
Returns
the stored value a value is stored deref constexpr T &operator*();

Definition at line 5903 of file sol.hpp.

◆ operator*() [2/4]

template<class T>
constexpr const T& sol::optional< T >::operator* ( ) const &
inline

deref constexpr const T &operator*() const;

Definition at line 5909 of file sol.hpp.

◆ operator*() [3/4]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR T&& sol::optional< T >::operator* ( ) &&
inline

Definition at line 5914 of file sol.hpp.

◆ operator*() [4/4]

template<class T>
constexpr const T&& sol::optional< T >::operator* ( ) const &&
inline

Definition at line 5920 of file sol.hpp.

◆ operator->() [1/2]

template<class T>
constexpr const T* sol::optional< T >::operator-> ( ) const
inline
Returns
a pointer to the stored value a value is stored pointer constexpr const T *operator->() const;

Definition at line 5889 of file sol.hpp.

◆ operator->() [2/2]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR T* sol::optional< T >::operator-> ( )
inline

pointer constexpr T *operator->();

Definition at line 5895 of file sol.hpp.

◆ operator=() [1/6]

template<class T>
optional& sol::optional< T >::operator= ( nullopt_t  )
inlinenoexcept

Assignment to empty.

Destroys the current value if there is one.

Definition at line 5758 of file sol.hpp.

◆ operator=() [2/6]

template<class T>
optional& sol::optional< T >::operator= ( const optional< T > &  rhs)
default

Copy assignment.

Copies the value from rhs if there is one. Otherwise resets the stored value in *this.

◆ operator=() [3/6]

template<class T>
optional& sol::optional< T >::operator= ( optional< T > &&  rhs)
default

Move assignment.

Moves the value from rhs if there is one. Otherwise resets the stored value in *this.

◆ operator=() [4/6]

template<class T>
template<class U = T, detail::enable_assign_forward< T, U > * = nullptr>
optional& sol::optional< T >::operator= ( U &&  u)
inline

Assigns the stored value from u, destroying the old value if there was one. optional &operator=(U &&u);

Definition at line 5783 of file sol.hpp.

◆ operator=() [5/6]

template<class T>
template<class U , detail::enable_assign_from_other< T, U, const U &> * = nullptr>
optional& sol::optional< T >::operator= ( const optional< U > &  rhs)
inline

Converting copy assignment operator.

Copies the value from rhs if there is one. Otherwise resets the stored value in *this. optional &operator=(const optional<U> & rhs);

Definition at line 5800 of file sol.hpp.

◆ operator=() [6/6]

template<class T>
template<class U , detail::enable_assign_from_other< T, U, U > * = nullptr>
optional& sol::optional< T >::operator= ( optional< U > &&  rhs)
inline

Converting move assignment operator.

Moves the value from rhs if there is one. Otherwise resets the stored value in *this. optional &operator=(optional<U> && rhs);

Definition at line 5824 of file sol.hpp.

◆ or_else() [1/8]

template<class T>
template<class F , detail::enable_if_ret_void< F > * = nullptr>
optional<T> SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::or_else ( F &&  f) &
inline

Calls f if the optional is empty std::invoke_result_t<F> must be void or convertible to optional<T>. If *this has a value, returns *this. Otherwise, if f returns void, calls std::forward<F>(f) and returns std::nullopt. Otherwise, returns std::forward<F>(f)().

or_else template <class f>=""> optional<T> or_else (F &&f) &;

Definition at line 5439 of file sol.hpp.

◆ or_else() [2/8]

template<class T>
template<class F , detail::disable_if_ret_void< F > * = nullptr>
optional<T> SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::or_else ( F &&  f) &
inline

Definition at line 5449 of file sol.hpp.

◆ or_else() [3/8]

template<class T>
template<class F , detail::enable_if_ret_void< F > * = nullptr>
optional<T> sol::optional< T >::or_else ( F &&  f) &&
inline

or_else template <class f>=""> optional<T> or_else (F &&f) &&;

Definition at line 5456 of file sol.hpp.

◆ or_else() [4/8]

template<class T>
template<class F , detail::disable_if_ret_void< F > * = nullptr>
optional<T> SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::or_else ( F &&  f) &&
inline

Definition at line 5466 of file sol.hpp.

◆ or_else() [5/8]

template<class T>
template<class F , detail::enable_if_ret_void< F > * = nullptr>
optional<T> sol::optional< T >::or_else ( F &&  f) const &
inline

or_else template <class f>=""> optional<T> or_else (F &&f) const &;

Definition at line 5473 of file sol.hpp.

◆ or_else() [6/8]

template<class T>
template<class F , detail::disable_if_ret_void< F > * = nullptr>
optional<T> SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::or_else ( F &&  f) const &
inline

Definition at line 5483 of file sol.hpp.

◆ or_else() [7/8]

template<class T>
template<class F , detail::enable_if_ret_void< F > * = nullptr>
optional<T> sol::optional< T >::or_else ( F &&  f) const &&
inline

Definition at line 5490 of file sol.hpp.

◆ or_else() [8/8]

template<class T>
template<class F , detail::disable_if_ret_void< F > * = nullptr>
optional<T> sol::optional< T >::or_else ( F &&  f) const &&
inline

Definition at line 5500 of file sol.hpp.

◆ reset()

template<class T>
void sol::optional< T >::reset ( )
inlinenoexcept

Destroys the stored value if one exists, making the optional empty.

Definition at line 6000 of file sol.hpp.

◆ swap()

template<class T>
void sol::optional< T >::swap ( optional< T > &  rhs)
inlinenoexcept

Swaps this optional with the other.

If neither optionals have a value, nothing happens. If both have a value, the values are swapped. If one has a value, it is moved to the other and the movee is left valueless.

Definition at line 5868 of file sol.hpp.

◆ take() [1/4]

template<class T>
optional sol::optional< T >::take ( ) &
inline

Takes the value out of the optional, leaving it empty take

Definition at line 5631 of file sol.hpp.

◆ take() [2/4]

template<class T>
optional sol::optional< T >::take ( ) const &
inline

take

Definition at line 5638 of file sol.hpp.

◆ take() [3/4]

template<class T>
optional sol::optional< T >::take ( ) &&
inline

take

Definition at line 5645 of file sol.hpp.

◆ take() [4/4]

template<class T>
optional sol::optional< T >::take ( ) const &&
inline

take

Definition at line 5653 of file sol.hpp.

◆ value() [1/4]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR T& sol::optional< T >::value ( ) &
inline
Returns
the contained value if there is one, otherwise throws [bad_optional_access] value constexpr T &value();

Definition at line 5940 of file sol.hpp.

◆ value() [2/4]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR const T& sol::optional< T >::value ( ) const &
inline

value constexpr const T &value() const;

Definition at line 5951 of file sol.hpp.

◆ value() [3/4]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR T&& sol::optional< T >::value ( ) &&
inline

Definition at line 5961 of file sol.hpp.

◆ value() [4/4]

template<class T>
SOL_TL_OPTIONAL_11_CONSTEXPR const T&& sol::optional< T >::value ( ) const &&
inline

Definition at line 5973 of file sol.hpp.

◆ value_or() [1/2]

template<class T>
template<class U >
constexpr T sol::optional< T >::value_or ( U &&  u) const &
inline
Returns
the stored value if there is one, otherwise returns u value_or

Definition at line 5987 of file sol.hpp.

◆ value_or() [2/2]

template<class T>
template<class U >
SOL_TL_OPTIONAL_11_CONSTEXPR T sol::optional< T >::value_or ( U &&  u) &&
inline

value_or

Definition at line 5994 of file sol.hpp.

Member Data Documentation

◆ map [1/4]

template<class T>
template<class F >
decltype(optional_map_impl(std::declval<optional&>(), std::declval<F&&>())) SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::map(F &&f) &
inline

Carries out some operation on the stored object if there is one.

Returns
Let U be the result of std::invoke(std::forward<F>(f), value()). Returns a std::optional<U>. The return value is empty if *this is empty, otherwise an optional<U> is constructed from the return value of std::invoke(std::forward<F>(f), value()) and is returned.

map template <class f>=""> auto map(F &&f) &;

Definition at line 5401 of file sol.hpp.

◆ map [2/4]

template<class T>
template<class F >
decltype(optional_map_impl(std::declval<optional&&>(), std::declval<F&&>())) SOL_TL_OPTIONAL_11_CONSTEXPR sol::optional< T >::map(F &&f) &&
inline

map template <class f>=""> auto map(F &&f) &&;

Definition at line 5408 of file sol.hpp.

◆ map [3/4]

template<class T>
template<class F >
decltype(optional_map_impl(std::declval<const optional&>(), std::declval<F&&>())) constexpr sol::optional< T >::map(F &&f) const &
inline

map template <class f>=""> auto map(F &&f) const&;

Definition at line 5415 of file sol.hpp.

◆ map [4/4]

template<class T>
template<class F >
decltype(optional_map_impl(std::declval<const optional&&>(), std::declval<F&&>())) constexpr sol::optional< T >::map(F &&f) const &&
inline

map template <class f>=""> auto map(F &&f) const&&;

Definition at line 5423 of file sol.hpp.


The documentation for this class was generated from the following files:


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:12:57