4.4.1
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
Public Types | Public Member Functions
fcppt::optional::object< T > Class Template Reference

Detailed Description

template<typename T>
class fcppt::optional::object< T >

A class that makes values optional.

This class is a wrapper around std::optional that makes the following changes:

Template Parameters
TMust be move constructible.

See fcppt.optional for more information.

Public Types

using value_type = T
 The value type.
 

Public Member Functions

 object ()
 Constructs an empty optional.
 
 object (T const &)
 Constructs an optional by copying.
 
 object (T &&)
 Constructs an optional by moving.
 
T & get_unsafe ()
 Returns a reference to the current value.
 
T const & get_unsafe () const
 Returns a const reference to the current value.
 
bool has_value () const
 Returns whether the optional holds a value.
 

Member Typedef Documentation

◆ value_type

template<typename T >
using fcppt::optional::object< T >::value_type = T

The value type.

Constructor & Destructor Documentation

◆ object() [1/3]

template<typename T >
fcppt::optional::object< T >::object ( )

Constructs an empty optional.

Postcondition
has_value() will be false.

◆ object() [2/3]

template<typename T >
fcppt::optional::object< T >::object ( T const &  )
explicit

Constructs an optional by copying.

◆ object() [3/3]

template<typename T >
fcppt::optional::object< T >::object ( T &&  )
explicit

Constructs an optional by moving.

Member Function Documentation

◆ get_unsafe() [1/2]

template<typename T >
T & fcppt::optional::object< T >::get_unsafe ( )

Returns a reference to the current value.

Warning
The behaviour is undefined if has_value() is false.

◆ get_unsafe() [2/2]

template<typename T >
T const & fcppt::optional::object< T >::get_unsafe ( ) const

Returns a const reference to the current value.

Warning
The behaviour is undefined if has_value() is false.

◆ has_value()

template<typename T >
bool fcppt::optional::object< T >::has_value ( ) const

Returns whether the optional holds a value.