libfilezilla
Public Member Functions | List of all members
shared_optional< T, Init > Class Template Referencefinal

shared_optional is like std::shared_ptr but with relational operators acting like C++17's std::optional More...

#include <shared.hpp>

Public Member Functions

 shared_optional (shared_optional< T, Init > const &v)=default
 
 shared_optional (shared_optional< T, Init > &&v) noexcept=default
 
 shared_optional (const T &v)
 
void clear ()
 
T & get ()
 Gets a reference to the stored object. More...
 
const T & operator* () const
 
const T * operator-> () const
 
shared_optional< T, Init > & operator= (shared_optional< T, Init > const &v)=default
 
shared_optional< T, Init > & operator= (shared_optional< T, Init > &&v) noexcept=default
 
 operator bool () const
 
bool empty () const
 
Deep relational operators

If two instances point to different objects, those objects are compared. Empty instances are less than non-empty instances.

bool operator== (shared_optional< T, Init > const &cmp) const
 
bool operator== (T const &cmp) const
 
bool operator< (shared_optional< T, Init > const &cmp) const
 
bool operator< (T const &cmp) const
 
bool is_same (shared_optional< T, Init > const &cmp) const
 Only compares the pointers.
 
bool operator!= (const shared_optional< T, Init > &cmp) const
 
bool operator!= (T const &cmp) const
 

Detailed Description

template<typename T, bool Init = false>
class fz::shared_optional< T, Init >

shared_optional is like std::shared_ptr but with relational operators acting like C++17's std::optional

Template Parameters
Tthat can be stored in the shared_optional
Initcontrols whether the optional can be empty. If false, the default, it acts like a normal optional/shared_ptr. If true, it can never be empty.
See also
shared_value

This class is thread-safe under the following assumptions:

Member Function Documentation

◆ get()

T & get

Gets a reference to the stored object.

A new object is created it if is not set. Returned reference is unique, it is not shared.


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