5#ifndef TABLEAU_HYPER_OPTIONAL_HPP
6#define TABLEAU_HYPER_OPTIONAL_HPP
8#if !defined(__cplusplus) || (__cplusplus < 201703L)
9#define hyper_use_own_optional
12#ifdef hyper_use_own_optional
20#ifdef hyper_use_own_optional
22#define CONSTEXPR_OPTIONAL const
24#define CONSTEXPR_OPTIONAL constexpr
28#ifndef hyper_use_own_optional
30using optional = std::optional<T>;
31using bad_optional_access = std::bad_optional_access;
35 using std::exception::exception;
43 alignas(T)
char data_[
sizeof(T)];
65 typename = typename std::enable_if<!std::is_same<typename std::decay<U>::type,
optional<T>>::
value>::type>
75 template <typename Other>
76 bool operator==(const
optional<Other>& other) const noexcept {
77 return (exists_ == other.exists_) && ((!exists_) || (**
this == *other));
80 template <
typename Other>
89 explicit operator bool() const noexcept {
return exists_; }
121 template <
typename U>
123 return bool(*
this) ? **this :
static_cast<T
>(std::forward<U>(default_value));
127 template <
typename U>
129 return bool(*
this) ? std::move(**
this) :
static_cast<T
>(std::forward<U>(default_value));
151 template <typename... Args>
156 template <typename... Args>
157 void create(Args&&... args);
160 T* ptr() noexcept {
return exists_ ?
reinterpret_cast<T*
>(data_) :
nullptr; }
162 const T* ptr() const noexcept {
return exists_ ?
reinterpret_cast<const T*
>(data_) : nullptr; }
167#include <hyperapi/impl/optional.impl.hpp>
Surrogate for C++17 std::bad_optional_access
Surrogate for C++17 std::optional
T & operator*() &
Value access.
const T && operator*() const &&
Value access.
const T && value() const &&
Value access.
T value_or(U &&default_value) &&
Value or default.
void reset() noexcept
Reset.
T && operator*() &&
Value access.
T value_type
The value type.
const T & value() const &
Value access.
optional() noexcept=default
Constructor.
T value_or(U &&default_value) const &
Value or default.
T && value() &&
Value access.
bool operator!=(const optional< Other > &other) const noexcept
Comparison.
bool has_value() const noexcept
Checks whether *this contains a value.
void swap(optional &other)
Swap.
const T * operator->() const noexcept
Value access.
T & value() &
Value access.
const T & operator*() const &
Value access.
void emplace(Args &&... args)
Emplace.
T * operator->() noexcept
Value access.
The primary namespace of the Hyper API for C++.