swift
Classes | Public Member Functions | List of all members
swift::misc::Optional< T > Class Template Reference

Own implementation of std::optional. More...

Public Member Functions

 Optional () noexcept=default
 Default constructor.
 
 Optional (T value) noexcept(std::is_nothrow_move_constructible_v< T >)
 Construct from a value.
 
 Optional (std::nullptr_t) noexcept
 Construct from a nullptr, equivalent to default constructor.
 
 Optional (const Optional &other) noexcept(std::is_nothrow_copy_constructible_v< T >)
 Copy constructor.
 
 Optional (Optional &&other) noexcept(std::is_nothrow_move_constructible_v< T >)
 Move constructor.
 
Optionaloperator= (std::nullptr_t) noexcept
 Assign a nullptr.
 
Optionaloperator= (const Optional &other) noexcept(std::is_nothrow_copy_constructible_v< T >)
 Copy assignment.
 
Optionaloperator= (Optional &&other) noexcept(std::is_nothrow_move_constructible_v< T >)
 Move assignment.
 
 ~Optional ()
 Destructor.
 
 operator bool () const noexcept
 Explicit cast to bool, true if this Optional contains a value.
 
void reset () noexcept
 If object is valid, destroy to make it invalid.
 
T & operator* ()
 Dereference operator, returns reference to contained value, undefined if there is no value contained.
 
const T & operator* () const
 Dereference operator, returns reference to contained value, undefined if there is no value contained.
 
T * operator-> ()
 Indirection operator, returns pointer to contained value, undefined if there is no value contained.
 
const T * operator-> () const
 Indirection operator, returns pointer to contained value, undefined if there is no value contained.
 

Detailed Description

template<typename T>
class swift::misc::Optional< T >

Own implementation of std::optional.

Needed to work around lack of C++20 copyable lambda functions.

Definition at line 22 of file optional.h.


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