|
JUCE
|
A simple optional type. More...
#include <juce_Optional.h>
Public Member Functions | |
| 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. | |
| 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. | |
| ~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. | |
| template<typename... Args> | |
| Value & | emplace (Args &&... args) |
| void | swap (Optional &other) noexcept(std::is_nothrow_move_constructible< Value >::value &&detail::adlSwap::isNothrowSwappable< 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.
References placeholder.
Referenced by operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), Optional(), Optional(), Optional(), Optional(), and swap().
References placeholder.
|
noexcept |
References storage.
References Optional(), and placeholder.
References Optional(), placeholder, and storage.
|
noexcept |
References Optional(), and placeholder.
| Optional< Value >::Optional | ( | const Optional< Other > & | other | ) |
References hasValue(), Optional(), placeholder, and storage.
References Optional(), and reset().
|
noexcept |
References Optional().
| Optional & Optional< Value >::operator= | ( | U && | value | ) |
References Optional(), and storage.
Maintains the strong exception safety guarantee.
References Optional().
|
noexcept |
References Optional().
| Optional & Optional< Value >::operator= | ( | const Optional< Other > & | other | ) |
Maintains the strong exception safety guarantee.
References Optional().
References storage.
Referenced by operator*(), and operator*().
References storage.
References operator->().
References operator->().
Referenced by operator!=(), operator!=(), operator!=(), operator<(), operator<(), operator<(), operator<=(), operator<=(), operator<=(), operator==(), operator==(), operator==(), operator>(), operator>(), operator>(), operator>=(), operator>=(), operator>=(), Optional(), and swap().
References operator*().
Referenced by emplace(), operator=(), and ~Optional().
| Value Optional< Value >::orFallback | ( | U && | fallback | ) | const |
Like std::optional::value_or.
References hasValue(), detail::adlSwap::isNothrowSwappable, Optional(), and swap().
Referenced by swap().
Referenced by Optional(), Optional(), Optional(), Optional(), Optional(), and Optional().
Referenced by emplace(), operator->(), operator->(), operator=(), Optional(), Optional(), and Optional().