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(); }
643 static_assert(std::is_copy_constructible_v<E>,
644 "error-type must be copy-constructible");
649 throw bad_expected_access(std::as_const(
error()));
654 static_assert(std::is_copy_constructible_v<E>,
655 "error-type must be copy-constructible");
661 throw bad_expected_access(std::as_const(
error()));
666 static_assert(std::is_copy_constructible_v<E> &&
667 std::is_constructible_v<E,
decltype(std::move(
error()))>);
670 return std::move(
val_);
673 throw bad_expected_access(std::move(
error()));
678 static_assert(std::is_copy_constructible_v<E> &&
679 std::is_constructible_v<E,
decltype(std::move(
error()))>);
682 return std::move(
val_);
685 throw bad_expected_access(std::move(
error()));
694 return std::addressof(
val_);
701 return std::addressof(
val_);
722 return std::move(
val_);
729 return std::move(
val_);
738 std::is_copy_constructible_v<T> && std::is_convertible_v<U &&, T>,
739 "T must be copy-constructible and convertible from U&&");
741 return has_value() ? **this :
static_cast<T
>(std::forward<U>(v));
748 std::is_move_constructible_v<T> && std::is_convertible_v<U &&, T>,
749 "T must be move-constructible and convertible from U&&");
751 return has_value() ? std::move(**
this) :
static_cast<T
>(std::forward<U>(v));
763 template <
class T2,
class E2>
764 requires(!std::is_void_v<T2>)
765 friend constexpr bool operator==(
const expected &lhs,
770 return static_cast<bool>(*lhs == *
rhs);
775 requires(!impl::is_expected<T2>)
776 friend constexpr bool operator==(
const expected &lhs,
const T2 &
rhs) {
777 return lhs.
has_value() &&
static_cast<bool>(*lhs ==
rhs);
786 return static_cast<bool>(lhs.
error() ==
rhs.error());
793 template <
class Func>
798 template <
class Func>
803 template <
class Func>
808 template <
class Func>
817 template <
class Func>
822 template <
class Func>
827 template <
class Func>
832 template <
class Func>
833 constexpr auto or_else(Func &&func)
const && {
841 template <
class Func>
846 template <
class Func>
851 template <
class Func>
856 template <
class Func>
865 val_ = std::forward<U>(u);
880 unex_ = std::forward<U>(u);
887#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 12
890 volatile char gcc_pr80635_workaround_maybe_uninitialized_;
897template <
class T,
class E>
898 requires(std::is_void_v<T>)
901 static_assert(!std::is_void_v<E>,
"E must not be void");
902 static_assert(!std::is_reference_v<T>,
"T must not be a reference");
903 static_assert(!std::is_same_v<T, std::remove_cv<std::in_place_t>>,
904 "T must not be std::in_place_t");
905 static_assert(!std::is_same_v<T, std::remove_cv<unexpected<E>>>,
906 "T must not be unexpected<E>");
907 static_assert(!std::is_reference_v<E>,
"E must not be a reference");
914 constexpr expected() noexcept : dummy_(), has_value_(true) {}
920 requires((std::is_copy_constructible_v<E> &&
921 !std::is_trivially_copy_constructible_v<E>))
922 : dummy_(), has_value_{other.has_value()} {
924 std::construct_at(std::addressof(unex_), other.unex_);
932 noexcept((std::is_nothrow_move_constructible_v<T>))
933 requires((std::is_move_constructible_v<E> &&
934 !std::is_trivially_move_constructible_v<E>))
935 : dummy_(), has_value_{other.has_value()} {
937 std::construct_at(std::addressof(unex_), std::move(other.unex_));
941 template <
class UF,
class GF>
942 static constexpr bool constructor_is_explicit =
943 (!std::is_convertible_v<UF, T> || !std::is_convertible_v<GF, E>);
945 template <
class U,
class G,
class UF,
class GF>
946 static constexpr bool can_value_convert_construct =
947 (std::is_void_v<U> && std::is_constructible_v<E, GF> &&
950 !std::is_constructible_v<unexpected<E>,
const expected<U, G> &> &&
954 template <
class U,
class G,
class UF = std::add_lvalue_reference_t<const U>,
955 class GF = const G &>
956 constexpr explicit(constructor_is_explicit<UF, GF>)
958 requires can_value_convert_construct<U, G, UF, GF>
961 std::construct_at(std::addressof(unex_), rhs.
error());
966 template <
class U,
class G,
class UF = U,
class GF = G>
967 constexpr explicit(constructor_is_explicit<UF, GF>)
968 expected(expected<U, G> &&rhs)
969 requires can_value_convert_construct<U, G, UF, GF>
970 : dummy_(), has_value_{rhs.
has_value()} {
972 std::construct_at(std::addressof(unex_), std::move(rhs.
error()));
980 constexpr explicit(!std::is_convertible_v<const G &, E>)
981 expected(
const unexpected<G> &
err)
982 requires std::is_constructible_v<E, const G &>
983 : unex_(
err.error()), has_value_{
false} {}
987 constexpr explicit(!std::is_convertible_v<G, E>)
988 expected(unexpected<G> &&
err)
989 requires std::is_constructible_v<E, G>
990 : unex_(std::move(
err.error())), has_value_{
false} {}
997 template <
class... Args>
998 constexpr explicit expected(std::in_place_t) : has_value_{true} {}
1001 template <
class... Args>
1003 requires std::is_constructible_v<E, Args...>
1004 : unex_(std::forward<Args>(args)...), has_value_{
false} {}
1007 template <
class U,
class... Args>
1010 requires std::is_constructible_v<E, std::initializer_list<U> &, Args...>
1011 : unex_(il, std::forward<Args>(args)...), has_value_{
false} {}
1016 constexpr expected &operator=(expected
const &other)
1017 requires((std::is_copy_assignable_v<E> &&
1018 std::is_copy_constructible_v<E>))
1020 if (other.has_value()) {
1023 assign_unex(other.unex_);
1030 constexpr expected &operator=(expected &&other)
1031 requires((std::is_move_assignable_v<E> &&
1032 std::is_move_constructible_v<E>))
1034 if (other.has_value()) {
1037 assign_unex(other.unex_);
1045 template <
class G,
class GF = const G &>
1046 constexpr expected &operator=(
const unexpected<G> &other)
1047 requires((std::is_constructible_v<E, GF> &&
1048 std::is_assignable_v<E &, GF>))
1050 assign_unex(other.error());
1056 template <
class G,
class GF = G>
1057 constexpr expected &operator=(unexpected<G> &&other)
1058 requires(std::is_constructible_v<E, GF> &&
1059 std::is_assignable_v<E &, GF>)
1061 assign_unex(std::move(other.error()));
1067#if defined(CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR)
1068 constexpr ~expected()
1069 requires((std::is_trivially_destructible_v<E>))
1073 constexpr ~expected() {
1080 constexpr void emplace() noexcept {
1088 constexpr void swap(expected &other)
1089 noexcept((std::is_nothrow_move_constructible_v<E> &&
1090 std::is_nothrow_swappable_v<E>))
1091 requires((std::is_swappable_v<E> &&
1092 std::is_move_constructible_v<E>))
1096 if (
bool(*
this) && bool(other)) {
1098 }
else if (!
bool(*
this) && !bool(other)) {
1099 swap(unex_, other.unex_);
1100 }
else if (
bool(*
this) && !
bool(other)) {
1101 std::construct_at(std::addressof(unex_), std::move(other.unex_));
1104 swap(has_value_, other.has_value_);
1105 }
else if (!
bool(*
this) &&
bool(other)) {
1110 constexpr bool has_value()
const {
return has_value_; }
1111 constexpr explicit operator bool() const noexcept {
return has_value(); }
1115 constexpr void value() const & {
1116 static_assert(std::is_copy_constructible_v<E>);
1119 throw bad_expected_access(std::as_const(
error()));
1123 constexpr void value() && {
1124 static_assert(std::is_move_constructible_v<E>);
1127 throw bad_expected_access(std::as_const(
error()));
1134 constexpr void operator*() const noexcept { assert(has_value()); }
1139 std::is_copy_constructible_v<T> && std::is_convertible_v<U &&, T>,
1140 "T must be copy-constructible and convertible from U&&");
1142 return has_value() ? **this :
static_cast<T
>(std::forward<U>(v));
1148 std::is_move_constructible_v<T> && std::is_convertible_v<U &&, T>,
1149 "T must be move-constructible and convertible from U&&");
1151 return has_value() ? std::move(**
this) : static_cast<T>(
std::forward<
U>(v));
1156 constexpr const error_type &&
error() const && {
return std::move(unex_); }
1165 template <
class T2,
class E2>
1166 friend constexpr bool operator==(
const expected &lhs,
1168 requires(std::is_void_v<T2>)
1181 friend constexpr bool operator==(
const expected &lhs,
1182 const unexpected<E2> &rhs) {
1183 if (lhs.has_value())
return false;
1185 return static_cast<bool>(lhs.error() == rhs.error());
1191 template <
class Func>
1192 constexpr auto and_then(Func &&func) & {
1196 template <
class Func>
1197 constexpr auto and_then(Func &&func) && {
1201 template <
class Func>
1202 constexpr auto and_then(Func &&func)
const & {
1206 template <
class Func>
1207 constexpr auto and_then(Func &&func)
const && {
1215 template <
class Func>
1216 constexpr auto or_else(Func &&func) & {
1220 template <
class Func>
1221 constexpr auto or_else(Func &&func) && {
1225 template <
class Func>
1226 constexpr auto or_else(Func &&func)
const & {
1230 template <
class Func>
1231 constexpr auto or_else(Func &&func)
const && {
1239 template <
class Func>
1240 constexpr auto transform(Func &&func) & {
1244 template <
class Func>
1245 constexpr auto transform(Func &&func) && {
1249 template <
class Func>
1250 constexpr auto transform(Func &&func)
const & {
1254 template <
class Func>
1255 constexpr auto transform(Func &&func)
const && {
1261 void assign_unex(
U &&u) {
1263 std::construct_at(std::addressof(unex_), std::forward<U>(u));
1266 unex_ = std::forward<U>(u);
1280template <
class Exp,
class Func>
1285 if constexpr (std::is_void_v<func_value_type>) {
1286 using func_return_type = std::invoke_result_t<Func>;
1290 if (!exp.has_value()) {
1291 return result_type{
stdx::unexpect, std::forward<Exp>(exp).error()};
1294 if constexpr (std::is_void_v<func_return_type>) {
1296 return result_type();
1298 return result_type(std::invoke(func));
1301 using func_return_type = std::invoke_result_t<Func, func_value_type>;
1305 if (!exp.has_value()) {
1306 return result_type{
stdx::unexpect, std::forward<Exp>(exp).error()};
1309 if constexpr (std::is_void_v<func_return_type>) {
1310 std::invoke(func, *std::forward<Exp>(exp));
1311 return result_type();
1313 return result_type(std::invoke(func, *std::forward<Exp>(exp)));
Definition: expected.h:899
E error_type
Definition: expected.h:910
E unex_
Definition: expected.h:1274
constexpr expected(expected &&other)=default
S dummy_
Definition: expected.h:1273
T value_type
Definition: expected.h:909
constexpr expected(expected &&other) noexcept((std::is_nothrow_move_constructible_v< T >))
Definition: expected.h:931
constexpr expected() noexcept
Definition: expected.h:914
constexpr expected(const expected &other)
Definition: expected.h:919
bool has_value_
Definition: expected.h:1277
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:782
constexpr T & emplace(Args &&...args) noexcept
Definition: expected.h:551
constexpr auto or_else(Func &&func) &
Definition: expected.h:818
constexpr auto or_else(Func &&func) &&
Definition: expected.h:823
constexpr auto and_then(Func &&func) &&
Definition: expected.h:799
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:677
constexpr auto and_then(Func &&func) const &
Definition: expected.h:804
constexpr auto transform(Func &&func) &
Definition: expected.h:842
constexpr G & rhs
Definition: expected.h:377
constexpr auto transform(Func &&func) const &
Definition: expected.h:852
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:746
constexpr const error_type & error() const &
Definition: expected.h:755
constexpr error_type && error() &&
Definition: expected.h:758
constexpr const value_type * operator->() const noexcept
Definition: expected.h:691
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:886
constexpr const value_type & value() const &
Definition: expected.h:653
constexpr auto transform(Func &&func) const &&
Definition: expected.h:857
constexpr value_type value_or(U &&v) const &
Definition: expected.h:736
constexpr expected & operator=(U &&val)
Definition: expected.h:491
constexpr expected(expected &&other)=default
constexpr auto or_else(Func &&func) const &&
Definition: expected.h:833
static constexpr bool can_value_convert_construct
Definition: expected.h:353
constexpr auto transform(Func &&func) &&
Definition: expected.h:847
constexpr value_type * operator->() noexcept
Definition: expected.h:698
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:863
T value_type
Definition: expected.h:298
constexpr value_type & value() &
Definition: expected.h:642
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:665
constexpr auto or_else(Func &&func) const &
Definition: expected.h:828
constexpr const value_type && operator*() const &&noexcept
Definition: expected.h:719
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:757
constexpr auto and_then(Func &&func) const &&
Definition: expected.h:809
bool has_value_
Definition: expected.h:894
constexpr const error_type && error() const &&
Definition: expected.h:756
constexpr const value_type & operator*() const &noexcept
Definition: expected.h:705
T val_
Definition: expected.h:885
constexpr auto and_then(Func &&func) &
Definition: expected.h:794
constexpr value_type && operator*() &&noexcept
Definition: expected.h:726
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:712
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:874
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
void destroy_at(T *ptr)
Definition: my_alloc.h:462
Header for compiler-dependent features.
constexpr bool likely(bool expr)
Definition: my_compiler.h:57
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:1281
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