19 struct NontrivialEmptyType final
21 constexpr NontrivialEmptyType() noexcept {}
33 _detail::NontrivialEmptyType m_disengaged;
44 constexpr Nullable() : m_disengaged{}, m_hasValue(false) {}
51 constexpr Nullable(T initialValue)
noexcept(std::is_nothrow_move_constructible<T>::value)
52 : m_value(std::move(initialValue)), m_hasValue(true)
62 : m_disengaged{}, m_hasValue(other.m_hasValue)
66 ::new (
static_cast<void*
>(&m_value)) T(other.m_value);
76 : m_disengaged{}, m_hasValue(other.m_hasValue)
80 ::new (
static_cast<void*
>(&m_value)) T(std::move(other.m_value));
101 void Reset() noexcept(std::is_nothrow_destructible<T>::value)
117 void Swap(
Nullable& other)
noexcept(std::is_nothrow_move_constructible<T>::value)
121 if (other.m_hasValue)
124 swap(m_value, other.m_value);
128 ::new (
static_cast<void*
>(&other.m_value)) T(std::move(m_value));
129 other.m_hasValue =
true;
133 else if (other.m_hasValue)
135 ::new (
static_cast<void*
>(&m_value)) T(std::move(other.m_value));
148 std::is_nothrow_move_constructible<T>::value)
180 typename std::enable_if<
183 typename std::remove_cv<typename std::remove_reference<U>::type>::type>::
186 std::is_scalar<U>::value
187 && std::is_same<T, typename std::decay<U>::type>::value)
191 && std::is_constructible<T, U>::value
192 && std::is_assignable<T&, U>::value,
196 std::is_nothrow_constructible<T, U>::value&& std::is_nothrow_assignable<T&, U>::value)
200 m_value = std::forward<U>(other);
204 ::new (
static_cast<void*
>(&m_value)) T(std::forward<U>(other));
216 template <
class... U>
217 T&
Emplace(U&&... Args)
noexcept(std::is_nothrow_constructible<T, U...>::value)
220 ::new (
static_cast<void*
>(&m_value)) T(std::forward<U>(Args)...);
230 bool HasValue() const noexcept {
return m_hasValue; }
262 return std::move(m_value);
271 constexpr explicit operator bool() const noexcept {
return HasValue(); }
281 constexpr const T*
operator->()
const {
return std::addressof(m_value); }
291 constexpr T*
operator->() {
return std::addressof(m_value); }
301 constexpr const T&
operator*() const& {
return m_value; }
321 constexpr T&&
operator*() && {
return std::move(m_value); }
331 constexpr const T&&
operator*() const&& {
return std::move(m_value); }
340 typename std::enable_if<
341 std::is_convertible<const T&, typename std::remove_cv<T>::type>::value
342 && std::is_convertible<U, T>::value,
345 constexpr typename std::remove_cv<T>::type
ValueOr(U&& other)
const&
352 return static_cast<typename std::remove_cv<T>::type
>(std::forward<U>(other));
362 typename std::enable_if<
363 std::is_convertible<T, typename std::remove_cv<T>::type>::value
364 && std::is_convertible<U, T>::value,
367 constexpr typename std::remove_cv<T>::type
ValueOr(U&& other) &&
371 return std::move(m_value);
374 return static_cast<typename std::remove_cv<T>::type
>(std::forward<U>(other));
Provide assert macros to use with pre-conditions.
#define AZURE_ASSERT_MSG(exp, msg)
Azure specific assert macro with message.
Definition azure_assert.hpp:53
Manages an optional contained value, i.e. a value that may or may not be present.
Definition nullable.hpp:30
constexpr T * operator->()
Accesses the contained value.
Definition nullable.hpp:291
Nullable & operator=(Nullable &&other) noexcept(std::is_nothrow_move_constructible< T >::value)
Assignment operator with move semantics.
Definition nullable.hpp:163
Nullable(const Nullable &other) noexcept(std::is_nothrow_copy_constructible< T >::value)
Constructs a Nullable by copying another Nullable.
Definition nullable.hpp:61
friend void swap(Nullable &lhs, Nullable &rhs) noexcept(std::is_nothrow_move_constructible< T >::value)
Invokes Azure::Nullable::Swap while having a lowercase name that satisfies swappable requirements (se...
Definition nullable.hpp:147
constexpr std::remove_cv< T >::type ValueOr(U &&other) const &
Get the contained value, returns other if value is absent.
Definition nullable.hpp:345
constexpr T && operator*() &&
Accesses the contained value.
Definition nullable.hpp:321
Nullable & operator=(const Nullable &other)
Assignment operator.
Definition nullable.hpp:154
constexpr const T * operator->() const
Accesses the contained value.
Definition nullable.hpp:281
const T & Value() const &noexcept
Get the contained value.
Definition nullable.hpp:236
T & Value() &noexcept
Get the contained value reference.
Definition nullable.hpp:247
bool HasValue() const noexcept
Check whether a value is contained.
Definition nullable.hpp:230
Nullable(Nullable &&other) noexcept(std::is_nothrow_move_constructible< T >::value)
Constructs a Nullable by moving in another Nullable.
Definition nullable.hpp:75
constexpr Nullable(T initialValue) noexcept(std::is_nothrow_move_constructible< T >::value)
Constructs a Nullable having an initialValue.
Definition nullable.hpp:51
constexpr Nullable()
Constructs a Nullable that represents the absence of value.
Definition nullable.hpp:44
void Swap(Nullable &other) noexcept(std::is_nothrow_move_constructible< T >::value)
Exchanges the contents.
Definition nullable.hpp:117
T & Emplace(U &&... Args) noexcept(std::is_nothrow_constructible< T, U... >::value)
Construct the contained value in-place.
Definition nullable.hpp:217
constexpr const T && operator*() const &&
Accesses the contained value.
Definition nullable.hpp:331
constexpr T & operator*() &
Accesses the contained value.
Definition nullable.hpp:311
~Nullable()
Destructs the Nullable, calling the destructor for the contained value if there is one.
Definition nullable.hpp:89
constexpr std::remove_cv< T >::type ValueOr(U &&other) &&
Get the contained value, returns other if value is absent.
Definition nullable.hpp:367
constexpr const T & operator*() const &
Accesses the contained value.
Definition nullable.hpp:301
void Reset() noexcept(std::is_nothrow_destructible< T >::value)
Destructs the contained value, if there is one.
Definition nullable.hpp:101
T && Value() &&noexcept
Get the contained value (as rvalue reference).
Definition nullable.hpp:258
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57