◆ alternative() [1/3]
◆ alternative() [2/3]
Constructs from null (empty state)
- Parameters
-
n | null value indicating empty state |
- Postcondition
- hasValue() == false
◆ alternative() [3/3]
Constructs with value present.
- Parameters
-
t | std::in_place_t tag to indicate value should be present |
- Postcondition
- hasValue() == true
◆ hasValue()
Checks if contains a value.
- Returns
- true if contains value, false if empty
◆ operator bool()
Boolean conversion operator.
- Returns
- true if contains value, false if empty
◆ operator=() [1/2]
Assignment from null to reset to empty state.
- Parameters
-
n | null value indicating empty state |
- Returns
- Reference to this alternative
- Postcondition
- hasValue() == false
Resets the alternative<void> to the empty state. This operation is equivalent to calling reset() but provides a more expressive syntax when working with null values. The assignment clears the "present" state and ensures the alternative is empty.
Example usage:
if (!flag) {
}
template<typename T>
}
A placeholder type representing the absence of a value.
Definition types.h:33
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
- Note
- This operation is noexcept and always succeeds.
- See also
- reset()
◆ operator=() [2/2]
Assignment from in_place tag to set as present.
- Parameters
-
t | std::in_place_t tag to indicate value should be present |
- Returns
- Reference to this alternative
- Postcondition
- hasValue() == true
Sets the alternative<void> to the "present" state without storing any actual data. This is equivalent to calling set() but allows for more expressive syntax in template code.
Example usage:
flag = std::in_place;
template<typename T>
}
- Note
- This operation is noexcept and always succeeds.
- See also
- set()
◆ reset()
Resets to empty state.
- Postcondition
- hasValue() == false
◆ set()
Sets the alternative to have a value.
- Postcondition
- hasValue() == true
◆ swap()
Swaps contents with another alternative<void>
- Parameters
-
other | Alternative to swap with |
- Note
- No-throw guarantee
The documentation for this class was generated from the following file: