Qx v0.6
Qt Extensions Library
|
The SetOnce template class acts as a container for a value that can only be set once. More...
#include <qx/core/qx-setonce.h>
Public Member Functions | |
SetOnce (T initial, C &&comp=C()) | |
bool | isSet () const |
operator bool () const | |
const T & | operator* () const |
const T * | operator-> () const |
SetOnce< T, C > & | operator= (const T &value) |
void | reset () |
const T & | value () const |
The optional C template parameter (defaults to void
) can be used to provide a comparator (such as std::equal_to), which is then used to reject assignment if the passed value is the same as the containers default.
|
inline |
Creates a SetOnce container that holds the initial value initial.
The container is initially unset and only holds this value until it is set.
When C is not void
, comp is used to compare the input value to the container's default value when performing an assignment.
|
inline |
Returns true
if the containers value has been set; otherwise returns false
.
|
inlineexplicit |
Produces the boolean value true
if the container is set; otherwise, produces false
.
|
inline |
Same as value().
|
inline |
Allows access to members of T for the value of the container.
|
inline |
Sets the value of the container to value. If C is not void
and value is the same as the container's default value, the container is not considered to be set.
To clarify:
Once the containers value has been set it cannot be changed again until it is reset.
|
inline |
Resets the container to its initial state.
The containers value will revert to the value specified in its constructor and will be considered unset.
|
inline |
Returns the current value of the container.