PCL
|
An object that can be in a defined or undefined state. More...
#include <Optional.h>
Public Member Functions | |
Optional () | |
Optional (const Optional &)=default | |
Optional (const T &value) | |
bool | IsDefined () const |
operator const T & () const | |
const T & | operator() () const |
bool | operator< (const Optional &x) const |
bool | operator< (const T &value) const |
Optional & | operator= (const Optional &x) |
Optional & | operator= (const T &value) |
Optional & | operator= (Optional &&x) |
bool | operator== (const Optional &x) const |
bool | operator== (const T &value) const |
const T & | OrElse (const T &value) const |
template<class E > | |
const T & | OrElseThrow (const Exception &exception) const |
const T & | OrElseThrow (const String &message) const |
void | Undefine () |
Optional stores an instance of the template argument T along with a defined state Boolean flag. Optional objects update their defined state automatically as they are created, copied and assigned.
This class is useful to deal with objects that can be defined optionally, when it is inconvenient to manage the object's value and its defined state as two separate items. Optional offers the power of encapsulation in object-oriented languages to solve these problems efficiently.
Definition at line 81 of file Optional.h.
|
inline |
Constructs an undefined Optional object.
The value instance will be default-constructed implicitly, which means that the type T must provide valid default construction semantics.
Definition at line 91 of file Optional.h.
|
default |
Copy constructor.
The value instance will be copy-constructed implicitly, which means that the type T must provide valid copy construction semantics if this constructor is invoked.
|
inline |
Constructs a defined Optional object with the specified value.
Definition at line 113 of file Optional.h.
|
inline |
Returns true if this Optional object has been defined.
Definition at line 180 of file Optional.h.
Referenced by pcl::AstrometricMetadata::CopyTimeAndLocationMetadata().
|
inline |
Type conversion operator. Returns a reference to the value stored in this Optional object.
If this object is undefined, the returned value may be unpredictable, depending on construction semantics for the type T.
Definition at line 158 of file Optional.h.
|
inline |
Returns a reference to the value stored in this Optional object.
If this object is undefined, the returned value may be unpredictable, depending on construction semantics for the type T.
This function performs the same role as operator const T&(). It is required for cases where an automatic type conversion is not applicable.
Definition at line 172 of file Optional.h.
|
inline |
Less than relational operator. Returns true iff this object has been defined and either x has not been defined (defined objects always precede undefined ones), or the value in this object precedes the value in x.
Definition at line 256 of file Optional.h.
|
inline |
Less-than-value relational operator. Returns true iff this object has been defined and its value precedes the specified value.
Definition at line 265 of file Optional.h.
|
inline |
Copy assignment operator. Returns a reference to this object.
Definition at line 122 of file Optional.h.
|
inline |
Assigns the specified value to this object. Returns a reference to this object. After assigning a value, an Optional object will be in defined state.
Definition at line 144 of file Optional.h.
|
inline |
Move assignment operator. Returns a reference to this object.
Definition at line 132 of file Optional.h.
|
inline |
Equality operator. Returns true iff one of the following condition holds:
Definition at line 236 of file Optional.h.
|
inline |
Value equality operator. Returns true iff this object has been defined and its value equals the specified value.
Definition at line 245 of file Optional.h.
|
inline |
Returns the value stored in this object if it has been defined. Otherwise returns the specified value.
Definition at line 200 of file Optional.h.
|
inline |
Returns the value stored in this object if it has been defined. Otherwise throws the specified exception.
Definition at line 210 of file Optional.h.
|
inline |
Returns the value stored in this object if it has been defined. Otherwise throws an Error exception with the specified message.
Definition at line 221 of file Optional.h.
|
inline |
Undefines this Optional object. Assigns a default-constructed object of type T to the value of this object, and sets the internal defined flag to false.
Definition at line 190 of file Optional.h.