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>) {
179 noexcept(lhs.swap(rhs))) {
191template <
class T,
class E>
199template <
class T,
class E>
200constexpr bool is_expected<expected<T, E>> =
true;
206constexpr bool is_unexpected<unexpected<T>> =
true;
208template <
class NewT,
class OldT,
class... Args>
210 if constexpr (std::is_nothrow_constructible_v<NewT, Args...>) {
212 std::construct_at(new_val, std::forward<Args>(args)...);
213 }
else if constexpr (std::is_nothrow_move_constructible_v<NewT>) {
214 NewT tmp(std::forward<Args>(args)...);
217 std::construct_at(new_val, std::move(tmp));
219 OldT tmp(std::move(*old_val));
223 std::construct_at(new_val, std::forward<Args>(args)...);
225 std::construct_at(old_val, std::move(tmp));
235template <
class Exp,
class Func,
237requires(std::is_void_v<value_type> ? std::is_invocable_v<Func>
238 : std::is_invocable_v<Func, value_type>)
240 if constexpr (std::is_void_v<value_type>) {
241 using Ret = std::invoke_result_t<Func>;
243 static_assert(stdx::impl::is_expected<Ret>,
244 "Func must return a stdx::expected<>");
246 if (exp.has_value()) {
247 return std::invoke(func);
252 using Ret = std::invoke_result_t<Func, value_type>;
254 static_assert(stdx::impl::is_expected<Ret>,
255 "Func must return a stdx::expected<>");
257 if (exp.has_value()) {
258 return std::invoke(func, *std::forward<Exp>(exp));
265template <
class Exp,
class Func,
267requires std::is_invocable_v<Func, error_type>
271 std::remove_cvref_t<std::invoke_result_t<Func, error_type>>, Exp>,
272 "Func must return an expected<>");
274 if (exp.has_value()) {
275 return std::forward<Exp>(exp);
278 return std::invoke(std::forward<Func>(func), std::forward<Exp>(exp).
error());
283template <
class T,
class E>
286 static_assert(!std::is_void_v<E>,
"E must not be void");
287 static_assert(!std::is_reference_v<T>,
"T must not be a reference");
288 static_assert(!std::is_function_v<T>,
"T must not be a function");
289 static_assert(!std::is_same_v<std::remove_cv_t<T>, std::in_place_t>,
290 "T must not be std::in_place_t");
291 static_assert(!std::is_same_v<std::remove_cv_t<T>,
unexpect_t>,
292 "T must not be stdx::unexpect_t");
293 static_assert(!std::is_same_v<T, std::remove_cv<unexpected<E>>>,
294 "T must not be unexpected<E>");
300 template <
typename U>
305 noexcept(
std::is_nothrow_default_constructible_v<T>)
306 requires
std::is_default_constructible_v<T>
313 noexcept((std::is_nothrow_copy_constructible_v<T> &&
314 std::is_nothrow_copy_constructible_v<E>))
315 requires((std::is_copy_constructible_v<T> &&
316 std::is_copy_constructible_v<E> &&
317 (!std::is_trivially_copy_constructible_v<T> ||
318 !std::is_trivially_copy_constructible_v<E>)))
321 std::construct_at(std::addressof(
val_), other.val_);
323 std::construct_at(std::addressof(
unex_), other.unex_);
331 noexcept((std::is_nothrow_move_constructible_v<E> &&
332 std::is_nothrow_move_constructible_v<T>))
333 requires((std::is_move_constructible_v<T> &&
334 std::is_move_constructible_v<E> &&
335 (!std::is_trivially_move_constructible_v<T> ||
336 !std::is_trivially_move_constructible_v<E>)))
339 std::construct_at(std::addressof(
val_), std::move(other.val_));
341 std::construct_at(std::addressof(
unex_), std::move(other.unex_));
345 template <
class UF,
class GF>
347 !std::is_convertible_v<UF, T> || !std::is_convertible_v<GF, E>;
350 template <
class U,
class G,
class UF,
class GF>
352 (std::is_constructible_v<T, UF> &&
353 std::is_constructible_v<E, GF> &&
354 !std::is_constructible_v<T, expected<U, G> &> &&
355 !std::is_constructible_v<T, expected<U, G>> &&
356 !std::is_constructible_v<T, const expected<U, G> &> &&
357 !std::is_constructible_v<T, const expected<U, G>> &&
358 !std::is_convertible_v<expected<U, G> &, T> &&
359 !std::is_convertible_v<expected<U, G>, T> &&
360 !std::is_convertible_v<const expected<U, G> &, T> &&
361 !std::is_convertible_v<const expected<U, G>, T> &&
364 !std::is_constructible_v<unexpected<E>,
const expected<U, G> &> &&
368 template <
class U,
class G,
class UF = std::add_lvalue_reference_t<const U>,
369 class GF = const G &>
370 constexpr explicit(constructor_is_explicit<UF, GF>)
372 requires can_value_convert_construct<U, G, UF, GF>
374 if (
rhs.has_value()) {
375 std::construct_at(std::addressof(
val_), std::forward<UF>(*
rhs));
377 std::construct_at(std::addressof(
unex_), std::forward<GF>(
rhs.error()));
382 template <
class U,
class G,
class UF = U,
class GF = G>
383 constexpr explicit(constructor_is_explicit<UF, GF>)
385 requires can_value_convert_construct<U, G, UF, GF>
387 if (
rhs.has_value()) {
388 std::construct_at(std::addressof(
val_), std::forward<UF>(*
rhs));
390 std::construct_at(std::addressof(
unex_), std::forward<GF>(
rhs.error()));
396 !std::is_same_v<std::in_place_t, std::remove_cvref_t<U>> &&
397 !std::is_same_v<expected, std::remove_cvref_t<U>> &&
398 std::is_constructible_v<T, U> &&
399 !impl::is_unexpected<std::remove_cvref_t<U>> &&
400 !impl::is_expected<std::remove_cvref_t<T>>;
403 template <
class U = T>
404 constexpr explicit(!std::is_convertible_v<U, T>)
expected(
U &&val)
405 requires can_construct_from_value_type<U>
410 constexpr explicit(!std::is_convertible_v<const G &, E>)
412 requires std::is_constructible_v<E, const G &>
417 constexpr explicit(!std::is_convertible_v<G, E>)
419 requires std::is_constructible_v<E, G>
423 template <
class... Args>
424 constexpr explicit expected(std::in_place_t, Args &&... args)
425 requires std::is_constructible_v<T, Args...>
429 template <
class U,
class... Args>
430 constexpr explicit expected(std::in_place_t, std::initializer_list<U> il,
432 requires std::is_constructible_v<T, std::initializer_list<U> &, Args...>
438 template <
class... Args>
440 requires std::is_constructible_v<E, Args &&...>
444 template <
class U,
class... Args>
447 requires std::is_constructible_v<E, std::initializer_list<U> &, Args...>
454 requires((std::is_copy_assignable_v<T> &&
455 std::is_copy_constructible_v<T> &&
456 std::is_copy_assignable_v<E> &&
457 std::is_copy_constructible_v<E> &&
458 (std::is_nothrow_move_constructible_v<T> ||
459 std::is_nothrow_move_constructible_v<E>))) {
460 if (other.has_value()) {
471 requires((std::is_move_assignable_v<T> &&
472 std::is_move_constructible_v<T> &&
473 std::is_move_assignable_v<E> &&
474 std::is_move_constructible_v<E> &&
475 (std::is_nothrow_move_constructible_v<T> ||
476 std::is_nothrow_move_constructible_v<E>))) {
477 if (other.has_value()) {
487 template <
class U = T>
489 requires((!std::is_same_v<expected<T, E>, std::remove_cvref_t<U>> &&
490 !impl::is_unexpected<std::remove_cvref_t<U>> &&
491 std::is_constructible_v<T, U> &&
492 std::is_assignable_v<T &, U> &&
493 (std::is_nothrow_constructible_v<T, U> ||
494 std::is_nothrow_move_constructible_v<T> ||
495 std::is_nothrow_move_constructible_v<E>))) {
502 template <
class G,
class GF = const G &>
504 requires((std::is_constructible_v<E, GF> &&
505 std::is_assignable_v<E &, GF> &&
506 (std::is_nothrow_constructible_v<E, GF> ||
507 std::is_nothrow_move_constructible_v<T> ||
508 std::is_nothrow_move_constructible_v<E>))) {
515 template <
class G,
class GF = G>
517 requires((std::is_constructible_v<E, GF> &&
518 std::is_assignable_v<E &, GF> &&
519 (std::is_nothrow_constructible_v<E, GF> ||
520 std::is_nothrow_move_constructible_v<T> ||
521 std::is_nothrow_move_constructible_v<E>))) {
528#if defined(CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR)
529 constexpr ~expected()
requires((std::is_trivially_destructible_v<T> &&
530 std::is_trivially_destructible_v<E>)) =
543 template <
class... Args>
544 constexpr T &
emplace(Args &&... args)
noexcept
545 requires(std::is_nothrow_constructible_v<T, Args...>) {
553 return *std::construct_at(std::addressof(
val_),
554 std::forward<Args>(args)...);
557 template <
class U,
class... Args>
558 constexpr T &
emplace(std::initializer_list<U> il,
559 Args &&... args)
noexcept
560 requires(std::is_nothrow_constructible_v<T, std::initializer_list<U> &,
569 return *std::construct_at(std::addressof(
val_), il,
570 std::forward<Args>(args)...);
575 noexcept((std::is_nothrow_move_constructible_v<T> &&
576 std::is_nothrow_move_constructible_v<E> &&
577 std::is_nothrow_swappable_v<T> &&
578 std::is_nothrow_swappable_v<E>))
579 requires((std::is_swappable_v<T> &&
580 std::is_swappable_v<E> &&
581 std::is_move_constructible_v<T> &&
582 std::is_move_constructible_v<E> &&
583 (std::is_nothrow_move_constructible_v<T> ||
584 std::is_nothrow_move_constructible_v<E>))) {
587 if (
bool(*
this) && bool(other)) {
589 }
else if (!
bool(*
this) && !
bool(other)) {
591 }
else if (
bool(*
this) && !
bool(other)) {
592 if constexpr (std::is_nothrow_move_constructible_v<E>) {
597 std::construct_at(std::addressof(other.val_), std::move(
val_));
599 std::construct_at(std::addressof(
unex_), std::move(tmp));
602 std::construct_at(std::addressof(other.unex_), std::move(tmp));
610 std::construct_at(std::addressof(
unex_), std::move(other.unex_));
612 std::construct_at(std::addressof(
val_), std::move(tmp));
615 std::construct_at(std::addressof(
val_), std::move(tmp));
621 other.has_value_ =
true;
622 }
else if (!
bool(*
this) &&
bool(other)) {
628 constexpr explicit operator bool() const noexcept {
return has_value(); }
633#define LIKELY(x) (x) [[likely]]
637 static_assert(std::is_copy_constructible_v<E>,
638 "error-type must be copy-constructible");
643 throw bad_expected_access(std::as_const(
error()));
648 static_assert(std::is_copy_constructible_v<E>,
649 "error-type must be copy-constructible");
655 throw bad_expected_access(std::as_const(
error()));
660 static_assert(std::is_copy_constructible_v<E> &&
661 std::is_constructible_v<E,
decltype(std::move(
error()))>);
664 return std::move(
val_);
667 throw bad_expected_access(std::move(
error()));
672 static_assert(std::is_copy_constructible_v<E> &&
673 std::is_constructible_v<E,
decltype(std::move(
error()))>);
676 return std::move(
val_);
679 throw bad_expected_access(std::move(
error()));
690 return std::addressof(
val_);
697 return std::addressof(
val_);
718 return std::move(
val_);
725 return std::move(
val_);
734 std::is_copy_constructible_v<T> && std::is_convertible_v<U &&, T>,
735 "T must be copy-constructible and convertible from U&&");
737 return has_value() ? **this :
static_cast<T
>(std::forward<U>(v));
744 std::is_move_constructible_v<T> && std::is_convertible_v<U &&, T>,
745 "T must be move-constructible and convertible from U&&");
747 return has_value() ? std::move(**
this) :
static_cast<T
>(std::forward<U>(v));
759 template <
class T2,
class E2>
760 requires(!std::is_void_v<T2>)
761 friend constexpr bool
766 return static_cast<bool>(*lhs == *
rhs);
771 requires(!impl::is_expected<T2>)
772 friend constexpr bool
774 return lhs.
has_value() &&
static_cast<bool>(*lhs ==
rhs);
783 return static_cast<bool>(lhs.
error() ==
rhs.error());
790 template <
class Func>
795 template <
class Func>
800 template <
class Func>
805 template <
class Func>
814 template <
class Func>
819 template <
class Func>
824 template <
class Func>
829 template <
class Func>
830 constexpr auto or_else(Func &&func)
const && {
838 template <
class Func>
843 template <
class Func>
848 template <
class Func>
853 template <
class Func>
862 val_ = std::forward<U>(u);
877 unex_ = std::forward<U>(u);
884#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 12
887 volatile char gcc_pr80635_workaround_maybe_uninitialized_;
894template <
class T,
class E>
895requires(std::is_void_v<T>)
898 static_assert(!std::is_void_v<E>,
"E must not be void");
899 static_assert(!std::is_reference_v<T>,
"T must not be a reference");
900 static_assert(!std::is_same_v<T, std::remove_cv<std::in_place_t>>,
901 "T must not be std::in_place_t");
902 static_assert(!std::is_same_v<T, std::remove_cv<unexpected<E>>>,
903 "T must not be unexpected<E>");
904 static_assert(!std::is_reference_v<E>,
"E must not be a reference");
911 constexpr expected() noexcept : dummy_(), has_value_(true) {}
917 (std::is_copy_constructible_v<E> &&
918 !std::is_trivially_copy_constructible_v<E>))
919 : dummy_(), has_value_{other.has_value()} {
921 std::construct_at(std::addressof(unex_), other.unex_);
929 noexcept((std::is_nothrow_move_constructible_v<T>))
930 requires((std::is_move_constructible_v<E> &&
931 !std::is_trivially_move_constructible_v<E>))
932 : dummy_(), has_value_{other.has_value()} {
934 std::construct_at(std::addressof(unex_), std::move(other.unex_));
938 template <
class UF,
class GF>
939 static constexpr bool constructor_is_explicit =
940 (!std::is_convertible_v<UF, T> || !std::is_convertible_v<GF, E>);
942 template <
class U,
class G,
class UF,
class GF>
943 static constexpr bool can_value_convert_construct =
944 (std::is_void_v<U> && std::is_constructible_v<E, GF> &&
947 !std::is_constructible_v<unexpected<E>,
const expected<U, G> &> &&
951 template <
class U,
class G,
class UF = std::add_lvalue_reference_t<const U>,
952 class GF = const G &>
953 constexpr explicit(constructor_is_explicit<UF, GF>)
955 requires can_value_convert_construct<U, G, UF, GF>
958 std::construct_at(std::addressof(unex_), rhs.
error());
963 template <
class U,
class G,
class UF = U,
class GF = G>
964 constexpr explicit(constructor_is_explicit<UF, GF>)
965 expected(expected<U, G> &&rhs)
966 requires can_value_convert_construct<U, G, UF, GF>
967 : dummy_(), has_value_{rhs.
has_value()} {
969 std::construct_at(std::addressof(unex_), std::move(rhs.
error()));
977 constexpr explicit(!std::is_convertible_v<const G &, E>)
978 expected(
const unexpected<G> &
err)
979 requires std::is_constructible_v<E, const G &>
980 : unex_(
err.error()), has_value_{
false} {}
984 constexpr explicit(!std::is_convertible_v<G, E>)
985 expected(unexpected<G> &&
err)
986 requires std::is_constructible_v<E, G>
987 : unex_(std::move(
err.error())), has_value_{
false} {}
994 template <
class... Args>
995 constexpr explicit expected(std::in_place_t) : has_value_{true} {}
998 template <
class... Args>
1000 requires std::is_constructible_v<E, Args...>
1001 : unex_(std::forward<Args>(args)...), has_value_{
false} {}
1004 template <
class U,
class... Args>
1007 requires std::is_constructible_v<E, std::initializer_list<U> &, Args...>
1008 : unex_(il, std::forward<Args>(args)...), has_value_{
false} {}
1013 constexpr expected &operator=(expected
const &other)
1014 requires((std::is_copy_assignable_v<E> &&
1015 std::is_copy_constructible_v<E>)) {
1016 if (other.has_value()) {
1019 assign_unex(other.unex_);
1026 constexpr expected &operator=(expected &&other)
1027 requires((std::is_move_assignable_v<E> &&
1028 std::is_move_constructible_v<E>)) {
1029 if (other.has_value()) {
1032 assign_unex(other.unex_);
1040 template <
class G,
class GF = const G &>
1041 constexpr expected &operator=(
const unexpected<G> &other)
1042 requires((std::is_constructible_v<E, GF> &&
1043 std::is_assignable_v<E &, GF>)) {
1044 assign_unex(other.error());
1050 template <
class G,
class GF = G>
1051 constexpr expected &operator=(unexpected<G> &&other)
1052 requires(std::is_constructible_v<E, GF> &&
1053 std::is_assignable_v<E &, GF>) {
1054 assign_unex(std::move(other.error()));
1060#if defined(CXX_HAS_CONDITIONAL_TRIVIAL_DESTRUCTOR)
1061 constexpr ~expected()
requires((std::is_trivially_destructible_v<E>)) =
1065 constexpr ~expected() {
1072 constexpr void emplace() noexcept {
1080 constexpr void swap(expected &other)
1081 noexcept((std::is_nothrow_move_constructible_v<E> &&
1082 std::is_nothrow_swappable_v<E>))
1083 requires((std::is_swappable_v<E> &&
1084 std::is_move_constructible_v<E>))
1088 if (
bool(*
this) && bool(other)) {
1090 }
else if (!
bool(*
this) && !bool(other)) {
1091 swap(unex_, other.unex_);
1092 }
else if (
bool(*
this) && !
bool(other)) {
1093 std::construct_at(std::addressof(unex_), std::move(other.unex_));
1096 swap(has_value_, other.has_value_);
1097 }
else if (!
bool(*
this) &&
bool(other)) {
1102 constexpr bool has_value()
const {
return has_value_; }
1103 constexpr explicit operator bool() const noexcept {
return has_value(); }
1107 constexpr void value() const & {
1108 static_assert(std::is_copy_constructible_v<E>);
1111 throw bad_expected_access(std::as_const(
error()));
1115 constexpr void value() && {
1116 static_assert(std::is_move_constructible_v<E>);
1119 throw bad_expected_access(std::as_const(
error()));
1126 constexpr void operator*() const noexcept { assert(has_value()); }
1131 std::is_copy_constructible_v<T> && std::is_convertible_v<U &&, T>,
1132 "T must be copy-constructible and convertible from U&&");
1134 return has_value() ? **this :
static_cast<T
>(std::forward<U>(v));
1140 std::is_move_constructible_v<T> && std::is_convertible_v<U &&, T>,
1141 "T must be move-constructible and convertible from U&&");
1143 return has_value() ? std::move(**
this) : static_cast<T>(
std::forward<
U>(v));
1148 constexpr const error_type &&
error() const && {
return std::move(unex_); }
1157 template <
class T2,
class E2>
1158 friend constexpr bool operator==(
const expected &lhs,
1160 requires(std::is_void_v<T2>) {
1172 friend constexpr bool operator==(
const expected &lhs,
1173 const unexpected<E2> &rhs) {
1174 if (lhs.has_value())
return false;
1176 return static_cast<bool>(lhs.error() == rhs.error());
1182 template <
class Func>
1183 constexpr auto and_then(Func &&func) & {
1187 template <
class Func>
1188 constexpr auto and_then(Func &&func) && {
1192 template <
class Func>
1193 constexpr auto and_then(Func &&func)
const & {
1197 template <
class Func>
1198 constexpr auto and_then(Func &&func)
const && {
1206 template <
class Func>
1207 constexpr auto or_else(Func &&func) & {
1211 template <
class Func>
1212 constexpr auto or_else(Func &&func) && {
1216 template <
class Func>
1217 constexpr auto or_else(Func &&func)
const & {
1221 template <
class Func>
1222 constexpr auto or_else(Func &&func)
const && {
1230 template <
class Func>
1231 constexpr auto transform(Func &&func) & {
1235 template <
class Func>
1236 constexpr auto transform(Func &&func) && {
1240 template <
class Func>
1241 constexpr auto transform(Func &&func)
const & {
1245 template <
class Func>
1246 constexpr auto transform(Func &&func)
const && {
1252 void assign_unex(
U &&u) {
1254 std::construct_at(std::addressof(unex_), std::forward<U>(u));
1257 unex_ = std::forward<U>(u);
1270template <
class Exp,
class Func>
1275 if constexpr (std::is_void_v<func_value_type>) {
1276 using func_return_type = std::invoke_result_t<Func>;
1280 if (!exp.has_value()) {
1281 return result_type{
stdx::unexpect, std::forward<Exp>(exp).error()};
1284 if constexpr (std::is_void_v<func_return_type>) {
1286 return result_type();
1288 return result_type(std::invoke(func));
1291 using func_return_type = std::invoke_result_t<Func, func_value_type>;
1295 if (!exp.has_value()) {
1296 return result_type{
stdx::unexpect, std::forward<Exp>(exp).error()};
1299 if constexpr (std::is_void_v<func_return_type>) {
1300 std::invoke(func, *std::forward<Exp>(exp));
1301 return result_type();
1303 return result_type(std::invoke(func, *std::forward<Exp>(exp)));
Definition: expected.h:896
constexpr expected(const expected &other)
Definition: expected.h:916
E error_type
Definition: expected.h:907
constexpr expected(expected &&other)=default
T value_type
Definition: expected.h:906
constexpr expected(expected &&other) noexcept((std::is_nothrow_move_constructible_v< T >))
Definition: expected.h:928
constexpr expected() noexcept
Definition: expected.h:911
bool has_value_
Definition: expected.h:1267
constexpr expected(const expected &other)=default
Definition: expected.h:284
constexpr expected & operator=(expected &&other)
Definition: expected.h:470
constexpr friend bool operator==(const expected &lhs, const unexpected< E2 > &rhs)
Definition: expected.h:779
constexpr auto or_else(Func &&func) &
Definition: expected.h:815
constexpr auto or_else(Func &&func) &&
Definition: expected.h:820
constexpr auto and_then(Func &&func) &&
Definition: expected.h:796
constexpr expected & operator=(const unexpected< G > &other)
Definition: expected.h:503
constexpr const value_type && value() const &&
Definition: expected.h:671
constexpr T & emplace(std::initializer_list< U > il, Args &&... args) noexcept
Definition: expected.h:558
constexpr auto and_then(Func &&func) const &
Definition: expected.h:801
constexpr auto transform(Func &&func) &
Definition: expected.h:839
constexpr G & rhs
Definition: expected.h:375
constexpr auto transform(Func &&func) const &
Definition: expected.h:849
E error_type
Definition: expected.h:297
constexpr value_type value_or(U &&v) &&
Definition: expected.h:742
constexpr const error_type & error() const &
Definition: expected.h:751
constexpr error_type && error() &&
Definition: expected.h:754
constexpr expected(std::in_place_t, std::initializer_list< U > il, Args &&... args)
Definition: expected.h:430
constexpr const value_type * operator->() const noexcept
Definition: expected.h:687
constexpr bool has_value() const
Definition: expected.h:627
E unex_
Definition: expected.h:883
constexpr const value_type & value() const &
Definition: expected.h:647
constexpr expected(stdx::unexpect_t, std::initializer_list< U > il, Args &&... args)
Definition: expected.h:445
constexpr auto transform(Func &&func) const &&
Definition: expected.h:854
constexpr value_type value_or(U &&v) const &
Definition: expected.h:732
constexpr expected & operator=(U &&val)
Definition: expected.h:488
constexpr expected(expected &&other)=default
constexpr auto or_else(Func &&func) const &&
Definition: expected.h:830
constexpr T & emplace(Args &&... args) noexcept
Definition: expected.h:544
static constexpr bool can_value_convert_construct
Definition: expected.h:351
constexpr auto transform(Func &&func) &&
Definition: expected.h:844
constexpr value_type * operator->() noexcept
Definition: expected.h:694
constexpr ~expected()
Definition: expected.h:534
static constexpr bool can_construct_from_value_type
Definition: expected.h:395
void assign_val(U &&u)
Definition: expected.h:860
T value_type
Definition: expected.h:296
constexpr value_type & value() &
Definition: expected.h:636
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:574
constexpr value_type && value() &&
Definition: expected.h:659
constexpr auto or_else(Func &&func) const &
Definition: expected.h:825
constexpr const value_type && operator*() const &&noexcept
Definition: expected.h:715
static constexpr bool constructor_is_explicit
Definition: expected.h:346
constexpr expected & operator=(unexpected< G > &&other)
Definition: expected.h:516
constexpr expected() noexcept(std::is_nothrow_default_constructible_v< T >)
Definition: expected.h:304
constexpr expected & operator=(expected const &other)
Definition: expected.h:453
constexpr error_type & error() &
Definition: expected.h:753
constexpr expected(stdx::unexpect_t, Args &&... args)
Definition: expected.h:439
constexpr auto and_then(Func &&func) const &&
Definition: expected.h:806
bool has_value_
Definition: expected.h:891
constexpr expected(std::in_place_t, Args &&... args)
Definition: expected.h:424
constexpr const error_type && error() const &&
Definition: expected.h:752
constexpr const value_type & operator*() const &noexcept
Definition: expected.h:701
T val_
Definition: expected.h:882
constexpr auto and_then(Func &&func) &
Definition: expected.h:791
constexpr value_type && operator*() &&noexcept
Definition: expected.h:722
constexpr expected(expected &&other) noexcept((std::is_nothrow_move_constructible_v< E > &&std::is_nothrow_move_constructible_v< T >))
Definition: expected.h:330
constexpr value_type & operator*() &noexcept
Definition: expected.h:708
constexpr expected(const expected &other) noexcept((std::is_nothrow_copy_constructible_v< T > &&std::is_nothrow_copy_constructible_v< E >))
Definition: expected.h:312
constexpr expected(const expected &other)=default
void assign_unex(U &&u)
Definition: expected.h:871
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
error_type error_
Definition: expected.h:184
constexpr const error_type & error() const &noexcept
Definition: expected.h:154
constexpr const error_type && error() const &&noexcept
Definition: expected.h:156
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
constexpr unexpected(std::in_place_t, Args &&... args) noexcept(std::is_nothrow_constructible_v< E, Args... >)
Definition: expected.h:132
constexpr friend void swap(unexpected &lhs, unexpected &rhs) noexcept(noexcept(lhs.swap(rhs)))
Definition: expected.h:178
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:173
error_type
Definition: error.h:36
#define U
Definition: ctype-tis620.cc:74
#define LIKELY(x)
Definition: expected.h:633
void destroy_at(T *ptr)
Definition: my_alloc.h:459
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:927
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:239
constexpr auto or_else_impl(Exp &&exp, Func &&func)
Definition: expected.h:268
constexpr bool is_unexpected
Definition: expected.h:203
constexpr void reinit_expected(NewT *new_val, OldT *old_val, Args &&... args)
Definition: expected.h:209
constexpr bool is_expected
Definition: expected.h:197
constexpr auto expected_transform_impl(Exp &&exp, Func &&func)
Definition: expected.h:1271
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