Type used for fields with default values of nothing
.
More...
template<typename T>
class bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >
Type used for fields with default values of nothing
.
This specialization is used for instance of T without allocators.
See the User's Manual for more details about default values of nothing
.
- See also
- For details of maybe's comparison operators, see
◆ value_type
The type of the value that may be inside the maybe.
◆ maybe() [1/5]
template<typename T >
bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::maybe |
( |
| ) |
|
|
default |
Create a maybe that holds nothing.
◆ maybe() [2/5]
template<typename T >
bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::maybe |
( |
const maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type > & |
| ) |
|
|
default |
◆ maybe() [3/5]
template<typename T >
bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::maybe |
( |
maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type > && |
| ) |
|
|
default |
Move a maybe.
- Note
- Unlike
std::optional
, a moved-from maybe holds nothing (compared to a moved-from T).
◆ maybe() [4/5]
template<typename T >
bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::maybe |
( |
const T & |
value | ) |
|
|
explicit |
Create a maybe that holds a value by copying value
.
◆ maybe() [5/5]
template<typename T >
bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::maybe |
( |
T && |
value | ) |
|
|
explicit |
Create a maybe that holds a value by moving from value
.
- Since
- 8.0.0
◆ emplace()
template<typename T >
template<typename... Args>
Construct a value in place.
- Since
- 8.0.0
◆ is_nothing()
Check if this object contains nothing.
- Returns
- true if this holds nothing; otherwise false.
◆ operator bool()
Check if this object contains a value.
- Returns
- true if this object holds a value; otherwise false.
- Since
- 8.0.0
◆ operator=() [1/2]
template<typename T >
maybe & bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::operator= |
( |
const T & |
value | ) |
|
Assign by copying a value.
◆ operator=() [2/2]
template<typename T >
maybe & bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::operator= |
( |
T && |
value | ) |
|
Move-assign from a value.
- Since
- 8.0.0
◆ set_nothing()
◆ set_value()
template<typename T >
T & bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::set_value |
( |
| ) |
|
Set the maybe to hold a value, if needed.
If this instance contains nothing, construct a default instance of T; otherwise, preserve the existing value.
- Returns
- A reference to the value.
◆ swap()
template<typename T >
void bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type >::swap |
( |
maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type > & |
that | ) |
|
Swap this object with that
.
◆ value() [1/4]
Get a reference to the value.
- Exceptions
-
◆ value() [2/4]
Get a constant reference to the value.
- Exceptions
-
◆ value() [3/4]
Get a reference to the value.
Will never throw, but has undefined behavior if the object contains nothing.
- Since
- 8.0.0
◆ value() [4/4]
Get a constant reference to the value.
Will never throw, but has undefined behavior if the object contains nothing.
- Since
- 8.0.0
◆ operator!=
template<typename T >
bool operator!= |
( |
const maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type > & |
lhs, |
|
|
const maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type > & |
rhs |
|
) |
| |
|
friend |
◆ operator==
template<typename T >
bool operator== |
( |
const maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type > & |
lhs, |
|
|
const maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type > & |
rhs |
|
) |
| |
|
friend |
Compares two maybes for value equality.
- Returns
- true if both maybes hold nothing; returns false if one maybe holds nothing and the other holds a values; otherwise, calls operator== with the two values.