|
| Optional () |
|
| Optional (Nullopt) noexcept |
|
template<typename U = Value, typename = std::enable_if_t<std::is_constructible<Value, U&&>::value && ! std::is_same<std::decay_t<U>, Optional>::value>> |
| Optional (U &&value) noexcept(noexcept(Value(std::forward< U >(value)))) |
|
| Optional (Optional &&other) noexcept(noexcept(std::declval< Optional >().constructFrom(other))) |
|
| Optional (const Optional &other) |
|
template<typename Other , typename = OptionalMoveConstructorEnabled<Value, Other>> |
| Optional (Optional< Other > &&other) noexcept(noexcept(std::declval< Optional >().constructFrom(other))) |
|
template<typename Other , typename = OptionalCopyConstructorEnabled<Value, Other>> |
| Optional (const Optional< Other > &other) |
|
Optional & | operator= (Nullopt) noexcept |
|
template<typename U = Value, typename = std::enable_if_t<std::is_nothrow_move_constructible<U>::value && std::is_nothrow_move_assignable<U>::value>> |
Optional & | operator= (Optional &&other) noexcept(noexcept(std::declval< Optional >().assign(std::declval< Optional & >()))) |
|
template<typename U = Value, typename = std::enable_if_t<! std::is_same<std::decay_t<U>, Optional>::value && std::is_constructible<Value, U>::value && std::is_assignable<Value&, U>::value && (! std::is_scalar<Value>::value || ! std::is_same<std::decay_t<U>, Value>::value)>> |
Optional & | operator= (U &&value) |
|
Optional & | operator= (const Optional &other) |
| Maintains the strong exception safety guarantee. More...
|
|
template<typename Other , typename = OptionalMoveAssignmentEnabled<Value, Other>> |
Optional & | operator= (Optional< Other > &&other) noexcept(noexcept(std::declval< Optional >().assign(other))) |
|
template<typename Other , typename = OptionalCopyAssignmentEnabled<Value, Other>> |
Optional & | operator= (const Optional< Other > &other) |
| Maintains the strong exception safety guarantee. More...
|
|
| ~Optional () noexcept |
|
Value * | operator-> () noexcept |
|
const Value * | operator-> () const noexcept |
|
Value & | operator* () noexcept |
|
const Value & | operator* () const noexcept |
|
| operator bool () const noexcept |
|
bool | hasValue () const noexcept |
|
void | reset () |
|
template<typename U > |
Value | orFallback (U &&fallback) const |
| Like std::optional::value_or. More...
|
|
template<typename... Args> |
Value & | emplace (Args &&... args) |
|
void | swap (Optional &other) noexcept(std::is_nothrow_move_constructible< Value >::value &&detail::adlSwap::isNothrowSwappable< Value >) |
|
template<typename
Value>
class Optional< Value >
A simple optional type.
Has similar (not necessarily identical!) semantics to std::optional.
This is intended to stand-in for std::optional while JUCE's minimum supported language standard is lower than C++17. When the minimum language standard moves to C++17, this class will probably be deprecated, in much the same way that juce::ScopedPointer was deprecated in favour of std::unique_ptr after C++11.
This isn't really intended to be used by JUCE clients. Instead, it's to be used internally in JUCE code, with an API close-enough to std::optional that the types can be swapped with fairly minor disruption at some point in the future, but without breaking any public APIs.