libfilezilla
|
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 |
shared_optional is like std::shared_ptr but with relational operators acting like C++17's std::optional
T | that can be stored in the shared_optional |
Init | controls 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. |
This class is thread-safe under the following assumptions:
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.