26#ifndef MYSQL_HARNESS_STDX_EXPECTED_H_
27#define MYSQL_HARNESS_STDX_EXPECTED_H_
37#include <initializer_list>
44#if defined(__cpp_concepts)
45#if __cpp_concepts >= 202002L
46#define CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR
47#elif defined(__clang_major__)
48#if __clang_major__ >= 15
51#define CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR
53#elif defined(__GNUC_MAJOR__)
54#if __GNUC_MAJOR__ >= 10
57#define CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR
60#define CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR
70class bad_expected_access;
73class bad_expected_access<void> :
public std::exception {
75 bad_expected_access() {}
76 bad_expected_access(
const bad_expected_access &) =
default;
77 bad_expected_access(bad_expected_access &&) =
default;
79 bad_expected_access &operator=(
const bad_expected_access &) =
default;
80 bad_expected_access &operator=(bad_expected_access &&) =
default;
82 ~bad_expected_access()
override =
default;
85 const char *what() const noexcept
override {
return "bad expected access"; }
89class bad_expected_access :
public bad_expected_access<void> {
91 explicit bad_expected_access(E e) : e_(
std::move(e)) {}
94 const E &
error() const &noexcept {
return e_; }
95 const E &&
error() const &&noexcept {
return e_; }
96 E &
error() &
noexcept {
return e_; }
97 E &&
error() &&
noexcept {
return e_; }
114 static_assert(!std::is_same<E, void>::value,
"E must not be void");
123 template <class Err = E>
125 noexcept(
std::is_nothrow_constructible_v<E, Err>)
127 !
std::is_same_v<
std::remove_cvref_t<Err>,
std::in_place_t> &&
128 std::is_constructible_v<E, Err>)
131 template <
class... Args>
132 constexpr explicit unexpected(std::in_place_t, Args &&...args)
133 noexcept(std::is_nothrow_constructible_v<E, Args...>)
134 requires std::constructible_from<E, Args &&...>
135 :
error_(std::forward<Args>(args)...) {}
137 template <
class U,
class... Args>
138 constexpr explicit unexpected(std::in_place_t, std::initializer_list<U> il,
140 noexcept(std::is_nothrow_constructible_v<E, std::initializer_list<U> &,
142 requires(std::constructible_from<E, std::initializer_list<U>,
144 :
error_(il, std::forward<Args>(args)...) {}
163 noexcept(std::is_nothrow_swappable_v<E>)
164 requires(std::is_swappable_v<E>)
180 noexcept(lhs.swap(rhs))) {
192template <
class T,
class E>
200template <
class T,
class E>
201constexpr bool is_expected<expected<T, E>> =
true;
207constexpr bool is_unexpected<unexpected<T>> =
true;
209template <
class NewT,
class OldT,
class... Args>
211 if constexpr (std::is_nothrow_constructible_v<NewT, Args...>) {
213 std::construct_at(new_val, std::forward<Args>(args)...);
214 }
else if constexpr (std::is_nothrow_move_constructible_v<NewT>) {
215 NewT tmp(std::forward<Args>(args)...);
218 std::construct_at(new_val, std::move(tmp));
220 OldT tmp(std::move(*old_val));
224 std::construct_at(new_val, std::forward<Args>(args)...);
226 std::construct_at(old_val, std::move(tmp));
236template <
class Exp,
class Func,
238 requires(std::is_void_v<value_type>
239 ? std::is_invocable_v<Func>
240 : std::is_invocable_v<Func, value_type>)
242 if constexpr (std::is_void_v<value_type>) {
243 using Ret = std::invoke_result_t<Func>;
245 static_assert(stdx::impl::is_expected<Ret>,
246 "Func must return a stdx::expected<>");
248 if (exp.has_value()) {
249 return std::invoke(func);
254 using Ret = std::invoke_result_t<Func, value_type>;
256 static_assert(stdx::impl::is_expected<Ret>,
257 "Func must return a stdx::expected<>");
259 if (exp.has_value()) {
260 return std::invoke(func, *std::forward<Exp>(exp));
267template <
class Exp,
class Func,
269 requires std::is_invocable_v<Func, error_type>
273 std::remove_cvref_t<std::invoke_result_t<Func, error_type>>, Exp>,
274 "Func must return an expected<>");
276 if (exp.has_value()) {
277 return std::forward<Exp>(exp);
280 return std::invoke(std::forward<Func>(func), std::forward<Exp>(exp).
error());
285template <
class T,
class E>
288 static_assert(!std::is_void_v<E>,
"E must not be void");
289 static_assert(!std::is_reference_v<T>,
"T must not be a reference");
290 static_assert(!std::is_function_v<T>,
"T must not be a function");
291 static_assert(!std::is_same_v<std::remove_cv_t<T>, std::in_place_t>,
292 "T must not be std::in_place_t");
293 static_assert(!std::is_same_v<std::remove_cv_t<T>,
unexpect_t>,
294 "T must not be stdx::unexpect_t");
295 static_assert(!std::is_same_v<T, std::remove_cv<unexpected<E>>>,
296 "T must not be unexpected<E>");
302 template <
typename U>
307 noexcept(
std::is_nothrow_default_constructible_v<T>)
308 requires
std::is_default_constructible_v<T>
315 noexcept((std::is_nothrow_copy_constructible_v<T> &&
316 std::is_nothrow_copy_constructible_v<E>))
317 requires((std::is_copy_constructible_v<T> &&
318 std::is_copy_constructible_v<E> &&
319 (!std::is_trivially_copy_constructible_v<T> ||
320 !std::is_trivially_copy_constructible_v<E>)))
323 std::construct_at(std::addressof(
val_), other.val_);
325 std::construct_at(std::addressof(
unex_), other.unex_);
333 noexcept((std::is_nothrow_move_constructible_v<E> &&
334 std::is_nothrow_move_constructible_v<T>))
335 requires((std::is_move_constructible_v<T> &&
336 std::is_move_constructible_v<E> &&
337 (!std::is_trivially_move_constructible_v<T> ||
338 !std::is_trivially_move_constructible_v<E>)))
341 std::construct_at(std::addressof(
val_), std::move(other.val_));
343 std::construct_at(std::addressof(
unex_), std::move(other.unex_));
347 template <
class UF,
class GF>
349 !std::is_convertible_v<UF, T> || !std::is_convertible_v<GF, E>;
352 template <
class U,
class G,
class UF,
class GF>
354 (std::is_constructible_v<T, UF> &&
355 std::is_constructible_v<E, GF> &&
356 !std::is_constructible_v<T, expected<U, G> &> &&
357 !std::is_constructible_v<T, expected<U, G>> &&
358 !std::is_constructible_v<T, const expected<U, G> &> &&
359 !std::is_constructible_v<T, const expected<U, G>> &&
360 !std::is_convertible_v<expected<U, G> &, T> &&
361 !std::is_convertible_v<expected<U, G>, T> &&
362 !std::is_convertible_v<const expected<U, G> &, T> &&
363 !std::is_convertible_v<const expected<U, G>, T> &&
366 !std::is_constructible_v<unexpected<E>,
const expected<U, G> &> &&
370 template <
class U,
class G,
class UF = std::add_lvalue_reference_t<const U>,
371 class GF = const G &>
372 constexpr explicit(constructor_is_explicit<UF, GF>)
374 requires can_value_convert_construct<U, G, UF, GF>
376 if (
rhs.has_value()) {
377 std::construct_at(std::addressof(
val_), std::forward<UF>(*
rhs));
379 std::construct_at(std::addressof(
unex_), std::forward<GF>(
rhs.error()));
384 template <
class U,
class G,
class UF = U,
class GF = G>
385 constexpr explicit(constructor_is_explicit<UF, GF>)
387 requires can_value_convert_construct<U, G, UF, GF>
389 if (
rhs.has_value()) {
390 std::construct_at(std::addressof(
val_), std::forward<UF>(*
rhs));
392 std::construct_at(std::addressof(
unex_), std::forward<GF>(
rhs.error()));
398 !std::is_same_v<std::in_place_t, std::remove_cvref_t<U>> &&
399 !std::is_same_v<expected, std::remove_cvref_t<U>> &&
400 std::is_constructible_v<T, U> &&
401 !impl::is_unexpected<std::remove_cvref_t<U>> &&
402 !impl::is_expected<std::remove_cvref_t<T>>;
405 template <
class U = T>
406 constexpr explicit(!std::is_convertible_v<U, T>)
expected(
U &&val)
407 requires can_construct_from_value_type<U>
412 constexpr explicit(!std::is_convertible_v<const G &, E>)
414 requires std::is_constructible_v<E, const G &>
420 requires std::is_constructible_v<E, G>
424 template <
class... Args>
425 constexpr explicit expected(std::in_place_t, Args &&...args)
426 requires std::is_constructible_v<T, Args...>
430 template <
class U,
class... Args>
431 constexpr explicit expected(std::in_place_t, std::initializer_list<U> il,
433 requires std::is_constructible_v<T, std::initializer_list<U> &, Args...>
439 template <
class... Args>
441 requires std::is_constructible_v<E, Args &&...>
445 template <
class U,
class... Args>
448 requires std::is_constructible_v<E, std::initializer_list<U> &, Args...>
455 requires((std::is_copy_assignable_v<T> &&
456 std::is_copy_constructible_v<T> &&
457 std::is_copy_assignable_v<E> &&
458 std::is_copy_constructible_v<E> &&
459 (std::is_nothrow_move_constructible_v<T> ||
460 std::is_nothrow_move_constructible_v<E>)))
462 if (other.has_value()) {
473 requires((std::is_move_assignable_v<T> &&
474 std::is_move_constructible_v<T> &&
475 std::is_move_assignable_v<E> &&
476 std::is_move_constructible_v<E> &&
477 (std::is_nothrow_move_constructible_v<T> ||
478 std::is_nothrow_move_constructible_v<E>)))
480 if (other.has_value()) {
490 template <
class U = T>
492 requires((!std::is_same_v<expected<T, E>, std::remove_cvref_t<U>> &&
493 !impl::is_unexpected<std::remove_cvref_t<U>> &&
494 std::is_constructible_v<T, U> &&
495 std::is_assignable_v<T &, U> &&
496 (std::is_nothrow_constructible_v<T, U> ||
497 std::is_nothrow_move_constructible_v<T> ||
498 std::is_nothrow_move_constructible_v<E>)))
506 template <
class G,
class GF = const G &>
508 requires((std::is_constructible_v<E, GF> &&
509 std::is_assignable_v<E &, GF> &&
510 (std::is_nothrow_constructible_v<E, GF> ||
511 std::is_nothrow_move_constructible_v<T> ||
512 std::is_nothrow_move_constructible_v<E>)))
520 template <
class G,
class GF = G>
522 requires((std::is_constructible_v<E, GF> &&
523 std::is_assignable_v<E &, GF> &&
524 (std::is_nothrow_constructible_v<E, GF> ||
525 std::is_nothrow_move_constructible_v<T> ||
526 std::is_nothrow_move_constructible_v<E>)))
534#if defined(CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR)
536 requires((std::is_trivially_destructible_v<T> &&
537 std::is_trivially_destructible_v<E>))
550 template <
class... Args>
552 requires(std::is_nothrow_constructible_v<T, Args...>)
561 return *std::construct_at(std::addressof(
val_),
562 std::forward<Args>(args)...);
565 template <
class U,
class... Args>
566 constexpr T &
emplace(std::initializer_list<U> il, Args &&...args)
noexcept
568 std::is_nothrow_constructible_v<T, std::initializer_list<U> &, Args...>)
577 return *std::construct_at(std::addressof(
val_), il,
578 std::forward<Args>(args)...);
583 noexcept((std::is_nothrow_move_constructible_v<T> &&
584 std::is_nothrow_move_constructible_v<E> &&
585 std::is_nothrow_swappable_v<T> &&
586 std::is_nothrow_swappable_v<E>))
587 requires((std::is_swappable_v<T> &&
588 std::is_swappable_v<E> &&
589 std::is_move_constructible_v<T> &&
590 std::is_move_constructible_v<E> &&
591 (std::is_nothrow_move_constructible_v<T> ||
592 std::is_nothrow_move_constructible_v<E>)))
596 if (
bool(*
this) && bool(other)) {
598 }
else if (!
bool(*
this) && !
bool(other)) {
600 }
else if (
bool(*
this) && !
bool(other)) {
601 if constexpr (std::is_nothrow_move_constructible_v<E>) {
606 std::construct_at(std::addressof(other.val_), std::move(
val_));
608 std::construct_at(std::addressof(
unex_), std::move(tmp));
611 std::construct_at(std::addressof(other.unex_), std::move(tmp));
619 std::construct_at(std::addressof(
unex_), std::move(other.unex_));
621 std::construct_at(std::addressof(
val_), std::move(tmp));
624 std::construct_at(std::addressof(
val_), std::move(tmp));
630 other.has_value_ =
true;
631 }
else if (!
bool(*
this) &&
bool(other)) {
637 constexpr explicit operator bool() const noexcept {
return has_value(); }
642#define LIKELY(x) (x) [[likely]]
646 static_assert(std::is_copy_constructible_v<E>,
647 "error-type must be copy-constructible");
652 throw bad_expected_access(std::as_const(
error()));
657 static_assert(std::is_copy_constructible_v<E>,
658 "error-type must be copy-constructible");
664 throw bad_expected_access(std::as_const(
error()));
669 static_assert(std::is_copy_constructible_v<E> &&
670 std::is_constructible_v<E,
decltype(std::move(
error()))>);
673 return std::move(
val_);
676 throw bad_expected_access(std::move(
error()));
681 static_assert(std::is_copy_constructible_v<E> &&
682 std::is_constructible_v<E,
decltype(std::move(
error()))>);
685 return std::move(
val_);
688 throw bad_expected_access(std::move(
error()));
699 return std::addressof(
val_);
706 return std::addressof(
val_);
727 return std::move(
val_);
734 return std::move(
val_);
743 std::is_copy_constructible_v<T> && std::is_convertible_v<U &&, T>,
744 "T must be copy-constructible and convertible from U&&");
746 return has_value() ? **this :
static_cast<T
>(std::forward<U>(v));
753 std::is_move_constructible_v<T> && std::is_convertible_v<U &&, T>,
754 "T must be move-constructible and convertible from U&&");
756 return has_value() ? std::move(**
this) :
static_cast<T
>(std::forward<U>(v));
768 template <
class T2,
class E2>
769 requires(!std::is_void_v<T2>)
770 friend constexpr bool operator==(
const expected &lhs,
775 return static_cast<bool>(*lhs == *
rhs);
780 requires(!impl::is_expected<T2>)
781 friend constexpr bool operator==(
const expected &lhs,
const T2 &
rhs) {
782 return lhs.
has_value() &&
static_cast<bool>(*lhs ==
rhs);
791 return static_cast<bool>(lhs.
error() ==
rhs.error());
798 template <
class Func>
803 template <
class Func>
808 template <
class Func>
813 template <
class Func>
822 template <
class Func>
827 template <
class Func>
832 template <
class Func>
837 template <
class Func>
838 constexpr auto or_else(Func &&func)
const && {
846 template <
class Func>
851 template <
class Func>
856 template <
class Func>
861 template <
class Func>
870 val_ = std::forward<U>(u);
885 unex_ = std::forward<U>(u);
892#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 12
895 volatile char gcc_pr80635_workaround_maybe_uninitialized_;
902template <
class T,
class E>
903 requires(std::is_void_v<T>)
906 static_assert(!std::is_void_v<E>,
"E must not be void");
907 static_assert(!std::is_reference_v<T>,
"T must not be a reference");
908 static_assert(!std::is_same_v<T, std::remove_cv<std::in_place_t>>,
909 "T must not be std::in_place_t");
910 static_assert(!std::is_same_v<T, std::remove_cv<unexpected<E>>>,
911 "T must not be unexpected<E>");
912 static_assert(!std::is_reference_v<E>,
"E must not be a reference");
919 constexpr expected() noexcept : dummy_(), has_value_(true) {}
925 requires((std::is_copy_constructible_v<E> &&
926 !std::is_trivially_copy_constructible_v<E>))
927 : dummy_(), has_value_{other.has_value()} {
929 std::construct_at(std::addressof(unex_), other.unex_);
937 noexcept((std::is_nothrow_move_constructible_v<T>))
938 requires((std::is_move_constructible_v<E> &&
939 !std::is_trivially_move_constructible_v<E>))
940 : dummy_(), has_value_{other.has_value()} {
942 std::construct_at(std::addressof(unex_), std::move(other.unex_));
946 template <
class UF,
class GF>
947 static constexpr bool constructor_is_explicit =
948 (!std::is_convertible_v<UF, T> || !std::is_convertible_v<GF, E>);
950 template <
class U,
class G,
class UF,
class GF>
951 static constexpr bool can_value_convert_construct =
952 (std::is_void_v<U> && std::is_constructible_v<E, GF> &&
955 !std::is_constructible_v<unexpected<E>,
const expected<U, G> &> &&
959 template <
class U,
class G,
class UF = std::add_lvalue_reference_t<const U>,
960 class GF = const G &>
961 constexpr explicit(constructor_is_explicit<UF, GF>)
963 requires can_value_convert_construct<U, G, UF, GF>
966 std::construct_at(std::addressof(unex_), rhs.
error());
971 template <
class U,
class G,
class UF = U,
class GF = G>
972 constexpr explicit(constructor_is_explicit<UF, GF>)
973 expected(expected<U, G> &&rhs)
974 requires can_value_convert_construct<U, G, UF, GF>
975 : dummy_(), has_value_{rhs.
has_value()} {
977 std::construct_at(std::addressof(unex_), std::move(rhs.
error()));
985 constexpr explicit(!std::is_convertible_v<const G &, E>)
986 expected(
const unexpected<G> &
err)
987 requires std::is_constructible_v<E, const G &>
988 : unex_(
err.error()), has_value_{
false} {}
992 constexpr explicit(!std::is_convertible_v<G, E>)
993 expected(unexpected<G> &&
err)
994 requires std::is_constructible_v<E, G>
995 : unex_(std::move(
err.error())), has_value_{
false} {}
1002 template <
class... Args>
1003 constexpr explicit expected(std::in_place_t) : has_value_{true} {}
1006 template <
class... Args>
1008 requires std::is_constructible_v<E, Args...>
1009 : unex_(std::forward<Args>(args)...), has_value_{
false} {}
1012 template <
class U,
class... Args>
1015 requires std::is_constructible_v<E, std::initializer_list<U> &, Args...>
1016 : unex_(il, std::forward<Args>(args)...), has_value_{
false} {}
1021 constexpr expected &operator=(expected
const &other)
1022 requires((std::is_copy_assignable_v<E> &&
1023 std::is_copy_constructible_v<E>))
1025 if (other.has_value()) {
1028 assign_unex(other.unex_);
1035 constexpr expected &operator=(expected &&other)
1036 requires((std::is_move_assignable_v<E> &&
1037 std::is_move_constructible_v<E>))
1039 if (other.has_value()) {
1042 assign_unex(other.unex_);
1050 template <
class G,
class GF = const G &>
1051 constexpr expected &operator=(
const unexpected<G> &other)
1052 requires((std::is_constructible_v<E, GF> &&
1053 std::is_assignable_v<E &, GF>))
1055 assign_unex(other.error());
1061 template <
class G,
class GF = G>
1062 constexpr expected &operator=(unexpected<G> &&other)
1063 requires(std::is_constructible_v<E, GF> &&
1064 std::is_assignable_v<E &, GF>)
1066 assign_unex(std::move(other.error()));
1072#if defined(CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR)
1073 constexpr ~expected()
1074 requires((std::is_trivially_destructible_v<E>))
1078 constexpr ~expected() {
1085 constexpr void emplace() noexcept {
1093 constexpr void swap(expected &other)
1094 noexcept((std::is_nothrow_move_constructible_v<E> &&
1095 std::is_nothrow_swappable_v<E>))
1096 requires((std::is_swappable_v<E> &&
1097 std::is_move_constructible_v<E>))
1101 if (
bool(*
this) && bool(other)) {
1103 }
else if (!
bool(*
this) && !bool(other)) {
1104 swap(unex_, other.unex_);
1105 }
else if (
bool(*
this) && !
bool(other)) {
1106 std::construct_at(std::addressof(unex_), std::move(other.unex_));
1109 swap(has_value_, other.has_value_);
1110 }
else if (!
bool(*
this) &&
bool(other)) {
1115 constexpr bool has_value()
const {
return has_value_; }
1116 constexpr explicit operator bool() const noexcept {
return has_value(); }
1120 constexpr void value() const & {
1121 static_assert(std::is_copy_constructible_v<E>);
1124 throw bad_expected_access(std::as_const(
error()));
1128 constexpr void value() && {
1129 static_assert(std::is_move_constructible_v<E>);
1132 throw bad_expected_access(std::as_const(
error()));
1139 constexpr void operator*() const noexcept { assert(has_value()); }
1144 std::is_copy_constructible_v<T> && std::is_convertible_v<U &&, T>,
1145 "T must be copy-constructible and convertible from U&&");
1147 return has_value() ? **this :
static_cast<T
>(std::forward<U>(v));
1153 std::is_move_constructible_v<T> && std::is_convertible_v<U &&, T>,
1154 "T must be move-constructible and convertible from U&&");
1156 return has_value() ? std::move(**
this) : static_cast<T>(
std::forward<
U>(v));
1161 constexpr const error_type &&
error() const && {
return std::move(unex_); }
1170 template <
class T2,
class E2>
1171 friend constexpr bool operator==(
const expected &lhs,
1173 requires(std::is_void_v<T2>)
1186 friend constexpr bool operator==(
const expected &lhs,
1187 const unexpected<E2> &rhs) {
1188 if (lhs.has_value())
return false;
1190 return static_cast<bool>(lhs.error() == rhs.error());
1196 template <
class Func>
1197 constexpr auto and_then(Func &&func) & {
1201 template <
class Func>
1202 constexpr auto and_then(Func &&func) && {
1206 template <
class Func>
1207 constexpr auto and_then(Func &&func)
const & {
1211 template <
class Func>
1212 constexpr auto and_then(Func &&func)
const && {
1220 template <
class Func>
1221 constexpr auto or_else(Func &&func) & {
1225 template <
class Func>
1226 constexpr auto or_else(Func &&func) && {
1230 template <
class Func>
1231 constexpr auto or_else(Func &&func)
const & {
1235 template <
class Func>
1236 constexpr auto or_else(Func &&func)
const && {
1244 template <
class Func>
1245 constexpr auto transform(Func &&func) & {
1249 template <
class Func>
1250 constexpr auto transform(Func &&func) && {
1254 template <
class Func>
1255 constexpr auto transform(Func &&func)
const & {
1259 template <
class Func>
1260 constexpr auto transform(Func &&func)
const && {
1266 void assign_unex(
U &&u) {
1268 std::construct_at(std::addressof(unex_), std::forward<U>(u));
1271 unex_ = std::forward<U>(u);
1284template <
class Exp,
class Func>
1289 if constexpr (std::is_void_v<func_value_type>) {
1290 using func_return_type = std::invoke_result_t<Func>;
1294 if (!exp.has_value()) {
1295 return result_type{
stdx::unexpect, std::forward<Exp>(exp).error()};
1298 if constexpr (std::is_void_v<func_return_type>) {
1300 return result_type();
1302 return result_type(std::invoke(func));
1305 using func_return_type = std::invoke_result_t<Func, func_value_type>;
1309 if (!exp.has_value()) {
1310 return result_type{
stdx::unexpect, std::forward<Exp>(exp).error()};
1313 if constexpr (std::is_void_v<func_return_type>) {
1314 std::invoke(func, *std::forward<Exp>(exp));
1315 return result_type();
1317 return result_type(std::invoke(func, *std::forward<Exp>(exp)));
Definition: expected.h:904
E error_type
Definition: expected.h:915
constexpr expected(expected &&other)=default
T value_type
Definition: expected.h:914
constexpr expected(expected &&other) noexcept((std::is_nothrow_move_constructible_v< T >))
Definition: expected.h:936
constexpr expected() noexcept
Definition: expected.h:919
constexpr expected(const expected &other)
Definition: expected.h:924
bool has_value_
Definition: expected.h:1281
constexpr expected(const expected &other)=default
Definition: expected.h:286
constexpr expected & operator=(expected &&other)
Definition: expected.h:472
constexpr friend bool operator==(const expected &lhs, const unexpected< E2 > &rhs)
Definition: expected.h:787
constexpr T & emplace(Args &&...args) noexcept
Definition: expected.h:551
constexpr auto or_else(Func &&func) &
Definition: expected.h:823
constexpr auto or_else(Func &&func) &&
Definition: expected.h:828
constexpr auto and_then(Func &&func) &&
Definition: expected.h:804
constexpr expected(std::in_place_t, std::initializer_list< U > il, Args &&...args)
Definition: expected.h:431
constexpr expected & operator=(const unexpected< G > &other)
Definition: expected.h:507
constexpr const value_type && value() const &&
Definition: expected.h:680
constexpr auto and_then(Func &&func) const &
Definition: expected.h:809
constexpr auto transform(Func &&func) &
Definition: expected.h:847
constexpr G & rhs
Definition: expected.h:377
constexpr auto transform(Func &&func) const &
Definition: expected.h:857
E error_type
Definition: expected.h:299
constexpr expected(std::in_place_t, Args &&...args)
Definition: expected.h:425
constexpr value_type value_or(U &&v) &&
Definition: expected.h:751
constexpr const error_type & error() const &
Definition: expected.h:760
constexpr error_type && error() &&
Definition: expected.h:763
constexpr const value_type * operator->() const noexcept
Definition: expected.h:696
constexpr T & emplace(std::initializer_list< U > il, Args &&...args) noexcept
Definition: expected.h:566
constexpr bool has_value() const
Definition: expected.h:636
E unex_
Definition: expected.h:891
constexpr const value_type & value() const &
Definition: expected.h:656
constexpr auto transform(Func &&func) const &&
Definition: expected.h:862
constexpr value_type value_or(U &&v) const &
Definition: expected.h:741
constexpr expected & operator=(U &&val)
Definition: expected.h:491
constexpr expected(expected &&other)=default
constexpr auto or_else(Func &&func) const &&
Definition: expected.h:838
static constexpr bool can_value_convert_construct
Definition: expected.h:353
constexpr auto transform(Func &&func) &&
Definition: expected.h:852
constexpr value_type * operator->() noexcept
Definition: expected.h:703
constexpr ~expected()
Definition: expected.h:541
constexpr expected(stdx::unexpect_t, Args &&...args)
Definition: expected.h:440
static constexpr bool can_construct_from_value_type
Definition: expected.h:397
void assign_val(U &&u)
Definition: expected.h:868
T value_type
Definition: expected.h:298
constexpr value_type & value() &
Definition: expected.h:645
constexpr void swap(expected &other) noexcept((std::is_nothrow_move_constructible_v< T > &&//std::is_nothrow_move_constructible_v< E > &&//std::is_nothrow_swappable_v< T > &&//std::is_nothrow_swappable_v< E >))
Definition: expected.h:582
constexpr value_type && value() &&
Definition: expected.h:668
constexpr auto or_else(Func &&func) const &
Definition: expected.h:833
constexpr const value_type && operator*() const &&noexcept
Definition: expected.h:724
static constexpr bool constructor_is_explicit
Definition: expected.h:348
constexpr expected & operator=(unexpected< G > &&other)
Definition: expected.h:521
constexpr expected() noexcept(std::is_nothrow_default_constructible_v< T >)
Definition: expected.h:306
constexpr expected & operator=(expected const &other)
Definition: expected.h:454
constexpr error_type & error() &
Definition: expected.h:762
constexpr auto and_then(Func &&func) const &&
Definition: expected.h:814
bool has_value_
Definition: expected.h:899
constexpr const error_type && error() const &&
Definition: expected.h:761
constexpr const value_type & operator*() const &noexcept
Definition: expected.h:710
T val_
Definition: expected.h:890
constexpr auto and_then(Func &&func) &
Definition: expected.h:799
constexpr value_type && operator*() &&noexcept
Definition: expected.h:731
constexpr expected(expected &&other) noexcept((std::is_nothrow_move_constructible_v< E > &&std::is_nothrow_move_constructible_v< T >))
Definition: expected.h:332
constexpr expected(stdx::unexpect_t, std::initializer_list< U > il, Args &&...args)
Definition: expected.h:446
constexpr value_type & operator*() &noexcept
Definition: expected.h:717
constexpr expected(const expected &other) noexcept((std::is_nothrow_copy_constructible_v< T > &&std::is_nothrow_copy_constructible_v< E >))
Definition: expected.h:314
constexpr expected(const expected &other)=default
void assign_unex(U &&u)
Definition: expected.h:879
Definition: expected.h:112
constexpr unexpected(unexpected &&) noexcept=default
constexpr void swap(unexpected &other) noexcept(std::is_nothrow_swappable_v< E >)
Definition: expected.h:162
constexpr error_type && error() &&noexcept
Definition: expected.h:155
constexpr error_type & error() &noexcept
Definition: expected.h:153
constexpr unexpected & operator=(unexpected &&) noexcept=default
constexpr unexpected(std::in_place_t, std::initializer_list< U > il, Args &&...args) noexcept(std::is_nothrow_constructible_v< E, std::initializer_list< U > &, Args... >)
Definition: expected.h:138
error_type error_
Definition: expected.h:185
constexpr const error_type & error() const &noexcept
Definition: expected.h:154
constexpr unexpected(std::in_place_t, Args &&...args) noexcept(std::is_nothrow_constructible_v< E, Args... >)
Definition: expected.h:132
constexpr const error_type && error() const &&noexcept
Definition: expected.h:156
constexpr friend void swap(unexpected &lhs, unexpected &rhs) noexcept(noexcept(lhs.swap(rhs)))
Definition: expected.h:179
E error_type
Definition: expected.h:116
constexpr unexpected(const unexpected &)=default
constexpr unexpected & operator=(const unexpected &)=default
constexpr friend bool operator==(const unexpected &lhs, const stdx::unexpected< E2 > &rhs)
Definition: expected.h:174
error_type
Definition: error.h:36
#define U
Definition: ctype-tis620.cc:74
#define LIKELY(x)
Definition: expected.h:642
void destroy_at(T *ptr)
Definition: my_alloc.h:462
Header for compiler-dependent features.
bool operator==(const my_thread_handle &a, const my_thread_handle &b)
Definition: my_thread.h:151
void error(const char *format,...)
uint16_t value_type
Definition: vt100.h:184
bool transform(const dd::Spatial_reference_system *source_srs, const Geometry &in, const dd::Spatial_reference_system *target_srs, const char *func_name, std::unique_ptr< Geometry > *out) noexcept
Transforms a geometry from one SRS to another.
Definition: transform.cc:216
Definition: http_server_component.cc:34
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:908
T value_or(T a, T b)
If a isn't set, return b.
Definition: loader.cc:605
Definition: gcs_xcom_synode.h:64
constexpr auto and_then_impl(Exp &&exp, Func &&func)
Definition: expected.h:241
constexpr auto or_else_impl(Exp &&exp, Func &&func)
Definition: expected.h:270
constexpr void reinit_expected(NewT *new_val, OldT *old_val, Args &&...args)
Definition: expected.h:210
constexpr bool is_unexpected
Definition: expected.h:204
constexpr bool is_expected
Definition: expected.h:198
constexpr auto expected_transform_impl(Exp &&exp, Func &&func)
Definition: expected.h:1285
constexpr unexpect_t unexpect
Definition: expected.h:109
unexpected(E) -> unexpected< E >
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:663
Definition: expected.h:105