89 template <
typename T, 
typename E>
    99   constexpr 
NoneType() noexcept = 
default;
   115   template <
typename T>
   120   template <
typename T>
   160 template <
typename T>
   161 struct [[nodiscard]] Some {
   162   static_assert(movable<T>, 
"Value type 'T' for 'Option<T>' must be movable");
   165       "Cannot use a reference for value type 'T' of 'Option<T>' , To prevent "   167       "type wrappers like std::reference_wrapper (stx::Ref) or any of the "   168       "`stx::ConstRef` or `stx::MutRef` specialized aliases instead");
   173   explicit constexpr 
Some(T && value) : value_(std::forward<T&&>(value)) {}
   175   constexpr Some(Some && rhs) = 
default;
   176   constexpr Some& operator=(Some&& rhs) = 
default;
   177   constexpr Some(Some 
const&) = 
default;
   178   constexpr Some& operator=(Some 
const&) = 
default;
   182   [[nodiscard]] constexpr T 
const& 
value() const& noexcept { 
return value_; }
   183   [[nodiscard]] constexpr T& 
value()& noexcept { 
return value_; }
   184   [[nodiscard]] constexpr T 
const value() const&& { 
return std::move(value_); }
   185   [[nodiscard]] constexpr T 
value()&& { 
return std::move(value_); }
   187   template <
typename U>
   189     static_assert(equality_comparable<T, U>);
   190     return value() == cmp.
value();
   193   template <
typename U>
   195     static_assert(equality_comparable<T, U>);
   196     return value() != cmp.
value();
   210   template <
typename Tp>
   242 template <
typename T>
   243 struct [[nodiscard]] 
Ok {
   244   static_assert(movable<T>, 
"Value type 'T' for 'Ok<T>' must be movable");
   247       "Cannot use a reference for value type 'T' of 'Ok<T>' , To prevent "   249       "type wrappers like std::reference_wrapper (stx::Ref) or any of the "   250       "`stx::ConstRef` or `stx::MutRef` specialized aliases instead");
   255   explicit constexpr 
Ok(T && value) : value_(std::forward<T&&>(value)) {}
   257   constexpr 
Ok(
Ok && rhs) = 
default;
   258   constexpr 
Ok& operator=(
Ok&& rhs) = 
default;
   259   constexpr 
Ok(
Ok const&) = 
default;
   260   constexpr 
Ok& operator=(
Ok const&) = 
default;
   264   template <
typename U>
   266     static_assert(equality_comparable<T, U>);
   267     return value() == cmp.
value();
   270   template <
typename U>
   272     static_assert(equality_comparable<T, U>);
   273     return value() != cmp.
value();
   276   template <
typename U>
   281   template <
typename U>
   286   [[nodiscard]] constexpr T 
const& 
value() const& noexcept { 
return value_; }
   287   [[nodiscard]] constexpr T& 
value()& noexcept { 
return value_; }
   288   [[nodiscard]] constexpr T 
const value() const&& { 
return std::move(value_); }
   289   [[nodiscard]] constexpr T 
value()&& { 
return std::move(value_); }
   294   template <
typename Tp, 
typename Er>
   327 template <
typename E>
   328 struct [[nodiscard]] 
Err {
   329   static_assert(movable<E>, 
"Error type 'E' for 'Err<E>' must be movable");
   332       "Cannot use a reference for error type 'E' of 'Err<E>' , To prevent "   334       "type wrappers like std::reference_wrapper (stx::Ref) or any of the "   335       "`stx::ConstRef` or `stx::MutRef` specialized aliases instead");
   340   explicit constexpr 
Err(E && value) : value_(std::forward<E&&>(value)) {}
   342   constexpr 
Err(
Err && rhs) = 
default;
   343   constexpr 
Err& operator=(
Err&& rhs) = 
default;
   344   constexpr 
Err(
Err const&) = 
default;
   345   constexpr 
Err& operator=(
Err const&) = 
default;
   349   template <
typename F>
   351     static_assert(equality_comparable<E, F>);
   352     return value() == cmp.
value();
   355   template <
typename F>
   357     static_assert(equality_comparable<E, F>);
   358     return value() != cmp.
value();
   361   template <
typename F>
   366   template <
typename F>
   371   [[nodiscard]] constexpr E 
const& 
value() const& noexcept { 
return value_; }
   372   [[nodiscard]] constexpr E& 
value()& noexcept { 
return value_; }
   373   [[nodiscard]] constexpr E 
const value() const&& { 
return std::move(value_); }
   374   [[nodiscard]] constexpr E 
value()&& { 
return std::move(value_); }
   379   template <
typename Tp, 
typename Er>
   390 template <
typename Tp>
   438 template <
typename T>
   439 struct [[nodiscard]] Option {
   443   static_assert(movable<T>, 
"Value type 'T' for 'Option<T>' must be movable");
   446       "Cannot use a reference for value type 'T' of 'Option<T>' , To prevent "   448       "type wrappers like std::reference_wrapper (stx::Ref) or any of the "   449       "`stx::ConstRef` or `stx::MutRef` specialized aliases instead");
   451   constexpr 
Option() noexcept : is_none_(true) {}
   454       : storage_value_(std::move(some.value_)), is_none_(false) {}
   457       : storage_value_(some.value()), is_none_(false) {
   458     static_assert(copy_constructible<T>);
   466   Option(Option && rhs) : is_none_(rhs.is_none_) {
   468       new (&storage_value_) T(std::move(rhs.storage_value_));
   474     if (is_some() && rhs.is_some()) {
   475       std::swap(storage_value_, rhs.storage_value_);
   476     } 
else if (is_some() && rhs.is_none()) {
   478       new (&rhs.storage_value_) T(std::move(storage_value_));
   481       rhs.is_none_ = 
false;
   482     } 
else if (is_none() && rhs.is_some()) {
   483       new (&storage_value_) T(std::move(rhs.storage_value_));
   484       rhs.storage_value_.~T();
   492   Option(Option 
const& rhs) : is_none_(rhs.is_none_) {
   493     static_assert(copy_constructible<T>);
   500     static_assert(copy_constructible<T>);
   502     if (is_some() && rhs.
is_some()) {
   504     } 
else if (is_some() && rhs.
is_none()) {
   507     } 
else if (is_none() && rhs.
is_some()) {
   521   template <
typename U>
   523     static_assert(equality_comparable<T, U>);
   524     if (is_some() && cmp.
is_some()) {
   525       return value_cref_() == cmp.value_cref_();
   526     } 
else if (is_none() && cmp.
is_none()) {
   533   template <
typename U>
   535     static_assert(equality_comparable<T, U>);
   536     if (is_some() && cmp.
is_some()) {
   537       return value_cref_() != cmp.value_cref_();
   538     } 
else if (is_none() && cmp.
is_none()) {
   545   template <
typename U>
   547     static_assert(equality_comparable<T, U>);
   549       return value_cref_() == cmp.
value();
   555   template <
typename U>
   557     static_assert(equality_comparable<T, U>);
   559       return value_cref_() != cmp.
value();
   587   [[nodiscard]] constexpr 
bool is_some() const noexcept { 
return !is_none(); }
   602   [[nodiscard]] constexpr 
bool is_none() const noexcept { 
return is_none_; }
   604   [[nodiscard]] 
operator bool() const noexcept { 
return is_some(); }
   623   template <
typename CmpType>
   624   [[nodiscard]] constexpr 
bool contains(CmpType 
const& cmp)
 const {
   625     static_assert(equality_comparable<T, CmpType>);
   627       return value_cref_() == cmp;
   646   template <
typename UnaryPredicate>
   647   [[nodiscard]] constexpr 
bool exists(UnaryPredicate && predicate)
 const {
   648     static_assert(invocable<UnaryPredicate&&, T const&>);
   652       return std::forward<UnaryPredicate&&>(predicate)(value_cref_());
   676   [[nodiscard]] T& 
value()& noexcept {
   698   [[nodiscard]] T 
const& 
value() const& noexcept {
   700     return value_cref_();
   704   [[deprecated(
"Use `unwrap()` instead")]] T value()&& = 
delete;
   706   [[deprecated(
"Use `unwrap()` instead")]] T 
const value() 
const&& = 
delete;
   723       "calling Option::as_cref() on an r-value, and therefore binding a "   724       "reference to an object that is marked to be moved")]]  
   725   [[nodiscard]] constexpr 
auto   726   as_cref() 
const&& noexcept->Option<
ConstRef<T>> = 
delete;
   761       "calling Option::as_ref() on an r-value, and therefore binding a "   762       "reference to an object that is marked to be moved")]]  
   763   [[nodiscard]] constexpr 
auto   764   as_ref()&& noexcept->Option<
MutRef<T>> = 
delete;
   767       "calling Option::as_ref() on an r-value, and therefore binding a "   768       "reference to an object that is marked to be moved")]]  
   769   [[nodiscard]] constexpr 
auto   770   as_ref() 
const&& noexcept->Option<
ConstRef<T>> = 
delete;
   793   [[nodiscard]] 
auto expect(std::string_view 
const& msg)&&->T {
   795       return std::move(value_ref_());
   825       return std::move(value_ref_());
   848       return std::move(value_ref_());
   850       return std::move(alt);
   867   template <
typename Fn>
   869     static_assert(invocable<Fn&&>);
   871       return std::move(value_ref_());
   873       return std::forward<Fn&&>(op)();
   899   template <
typename Fn>
   900   [[nodiscard]] constexpr 
auto map(Fn &&
   902     static_assert(invocable<Fn&&, T&&>);
   905           std::forward<Fn&&>(op)(std::move(value_ref_())));
   926   template <
typename Fn, 
typename A>
   927   [[nodiscard]] constexpr 
auto map_or(Fn && op,
   928                                       A && alt)&&->invoke_result<Fn&&, T&&> {
   929     static_assert(invocable<Fn&&, T&&>);
   931       return std::forward<Fn&&>(op)(std::move(value_ref_()));
   933       return std::forward<A&&>(alt);
   955   template <
typename Fn, 
typename AltFn>
   957       Fn && op, AltFn && alt)&&->invoke_result<Fn&&, T&&> {
   958     static_assert(invocable<Fn&&, T&&>);
   959     static_assert(invocable<AltFn&&>);
   962       return std::forward<Fn&&>(op)(std::move(value_ref_()));
   964       return std::forward<AltFn&&>(alt)();
   987   template <
typename E>
   988   [[nodiscard]] constexpr 
auto ok_or(E error)&&->Result<T, E> {
   990       return Ok<T>(std::move(value_ref_()));
   993       return Err<E>(std::forward<E>(error));
  1014   template <
typename Fn>
  1017     static_assert(invocable<Fn&&>);
  1019       return Ok<T>(std::move(value_ref_()));
  1051   template <
typename U>  
  1054       return std::forward<Option<U>&&>(cmp);
  1078   template <
typename Fn>
  1079   [[nodiscard]] constexpr 
auto and_then(Fn && op)&&->invoke_result<Fn&&, T&&> {
  1080     static_assert(invocable<Fn&&, T&&>);
  1082       return std::forward<Fn&&>(op)(std::move(value_ref_()));
  1107   template <
typename UnaryPredicate>
  1108   [[nodiscard]] constexpr 
auto filter(UnaryPredicate && predicate)&&->Option {
  1109     static_assert(invocable<UnaryPredicate&&, T const&>);
  1112     if (is_some() && std::forward<UnaryPredicate&&>(predicate)(value_cref_())) {
  1113       return std::move(*
this);
  1138   template <
typename UnaryPredicate>
  1140                                           predicate)&&->Option {
  1141     static_assert(invocable<UnaryPredicate&&, T const&>);
  1145         !std::forward<UnaryPredicate&&>(predicate)(value_cref_())) {
  1146       return std::move(*
this);
  1180   [[nodiscard]] constexpr 
auto OR(Option && alt)&&->Option {
  1182       return std::move(*
this);
  1184       return std::move(alt);
  1204   template <
typename Fn>
  1205   [[nodiscard]] constexpr 
auto or_else(Fn && op)&&->Option {
  1206     static_assert(invocable<Fn&&>);
  1208       return std::move(*
this);
  1210       return std::forward<Fn&&>(op)();
  1239   [[nodiscard]] constexpr 
auto XOR(Option && alt)&&->Option {
  1240     if (is_some() && alt.is_none()) {
  1241       return std::move(*
this);
  1242     } 
else if (is_none() && alt.is_some()) {
  1243       return std::move(alt);
  1267   [[nodiscard]] constexpr 
auto take()->Option {
  1269       auto some = 
Some<T>(std::move(value_ref_()));
  1298   [[nodiscard]] 
auto replace(T && replacement)->Option {
  1300       std::swap(replacement, value_ref_());
  1301       return Some<T>(std::move(replacement));
  1303       new (&storage_value_) T(std::forward<T&&>(replacement));
  1329   [[nodiscard]] 
auto replace(T 
const& replacement)->Option {
  1330     static_assert(copy_constructible<T>);
  1332       T copy = replacement;
  1333       std::swap(copy, value_ref_());
  1334       return Some<T>(std::move(copy));
  1336       new (&storage_value_) T(replacement);
  1353   [[nodiscard]] constexpr 
auto clone() const->Option {
  1354     static_assert(copy_constructible<T>);
  1356       return Some<T>(std::move(T(value_cref_())));
  1433     static_assert(std::is_default_constructible_v<T>);
  1435       return std::move(value_ref_());
  1469   template <
typename SomeFn, 
typename NoneFn>
  1471       SomeFn && some_fn, NoneFn && none_fn)&&->invoke_result<SomeFn&&, T&&> {
  1472     static_assert(invocable<SomeFn&&, T&&>);
  1473     static_assert(invocable<NoneFn&&>);
  1476       return std::forward<SomeFn&&>(some_fn)(std::move(value_ref_()));
  1478       return std::forward<NoneFn&&>(none_fn)();
  1482   template <
typename SomeFn, 
typename NoneFn>
  1484       SomeFn && some_fn, NoneFn && none_fn)&->invoke_result<SomeFn&&, T&> {
  1485     static_assert(invocable<SomeFn&&, T&>);
  1486     static_assert(invocable<NoneFn&&>);
  1489       return std::forward<SomeFn&&>(some_fn)(value_ref_());
  1491       return std::forward<NoneFn&&>(none_fn)();
  1495   template <
typename SomeFn, 
typename NoneFn>
  1496   [[nodiscard]] constexpr 
auto match(SomeFn && some_fn, NoneFn && none_fn)
  1497       const&->invoke_result<SomeFn&&, T 
const&> {
  1498     static_assert(invocable<SomeFn&&, T const&>);
  1499     static_assert(invocable<NoneFn&&>);
  1502       return std::forward<SomeFn&&>(some_fn)(value_cref_());
  1504       return std::forward<NoneFn&&>(none_fn)();
  1515   [[nodiscard]] constexpr T& value_ref_() { 
return storage_value_; }
  1517   [[nodiscard]] constexpr T 
const& value_cref_()
 const {
  1518     return storage_value_;
  1521   template <
typename Tp>
  1525 template <
typename U, 
typename T>
  1528   return option == cmp;
  1531 template <
typename U, 
typename T>
  1534   return option != cmp;
  1537 template <
typename T>
  1540   return option.is_none();
  1543 template <
typename T>
  1546   return option.is_some();
  1551 namespace internal {
  1557 template <
typename Tp, 
typename Er>
  1563 template <
typename Tp, 
typename Er>
  1638 template <
typename T, 
typename E>
  1639 struct [[nodiscard]] Result {
  1641   static_assert(movable<T>,
  1642                 "Value type 'T' for 'Result<T, E>' must be movable");
  1643   static_assert(movable<E>,
  1644                 "Error type 'E' for 'Result<T, E>' must be movable");
  1647       "Cannot use a reference for value type 'T' of 'Result<T, E>', To prevent "  1649       "type wrappers like std::reference_wrapper (stx::Ref) or any of the "  1650       "`stx::ConstRef` or `stx::MutRef` specialized aliases instead");
  1653       "Cannot use a reference for error type 'E' of 'Result<T, E>', To prevent "  1655       "type wrappers like std::reference_wrapper (stx::Ref) or any of the "  1656       "`stx::ConstRef` or `stx::MutRef` specialized aliases instead");
  1662       : storage_value_(std::forward<T>(result.value_)), is_ok_(true) {}
  1665       : storage_err_(std::forward<E>(err.value_)), is_ok_(false) {}
  1673       new (&storage_value_) T(std::move(rhs.storage_value_));
  1675       new (&storage_err_) E(std::move(rhs.storage_err_));
  1680     if (is_ok() && rhs.is_ok()) {
  1681       std::swap(value_ref_(), rhs.value_ref_());
  1682     } 
else if (is_ok() && rhs.is_err()) {
  1684       storage_value_.~T();
  1685       new (&storage_err_) E(std::move(rhs.storage_err_));
  1687     } 
else if (is_err() && rhs.is_ok()) {
  1689       new (&storage_value_) T(std::move(rhs.storage_value_));
  1693       std::swap(err_ref_(), rhs.err_ref_());  
  1699   Result(Result 
const& rhs) = 
delete;
  1700   Result& operator=(Result 
const& rhs) = 
delete;
  1704       storage_value_.~T();
  1710   template <
typename U>
  1712     static_assert(equality_comparable<T, U>);
  1714       return value_cref_() == cmp.
value();
  1720   template <
typename U>
  1722     static_assert(equality_comparable<T, U>);
  1724       return value_cref_() != cmp.
value();
  1730   template <
typename F>
  1732     static_assert(equality_comparable<E, F>);
  1736       return err_cref_() == cmp.
value();
  1740   template <
typename F>
  1742     static_assert(equality_comparable<E, F>);
  1746       return err_cref_() != cmp.
value();
  1750   template <
typename U, 
typename F>
  1752     static_assert(equality_comparable<T, U>);
  1753     static_assert(equality_comparable<E, F>);
  1755     if (is_ok() && cmp.
is_ok()) {
  1756       return value_cref_() == cmp.value_cref_();
  1757     } 
else if (is_err() && cmp.
is_err()) {
  1758       return err_cref_() == cmp.err_cref_();
  1764   template <
typename U, 
typename F>
  1766     static_assert(equality_comparable<T, U>);
  1767     static_assert(equality_comparable<E, F>);
  1769     if (is_ok() && cmp.
is_ok()) {
  1770       return value_cref_() != cmp.value_cref_();
  1771     } 
else if (is_err() && cmp.
is_err()) {
  1772       return err_cref_() != cmp.err_cref_();
  1792   [[nodiscard]] constexpr 
bool is_ok() const noexcept { 
return is_ok_; }
  1807   [[nodiscard]] constexpr 
bool is_err() const noexcept { 
return !is_ok(); }
  1809   [[nodiscard]] 
operator bool() const noexcept { 
return is_ok(); }
  1829   template <
typename CmpType>
  1830   [[nodiscard]] constexpr 
bool contains(CmpType 
const& cmp)
 const {
  1831     static_assert(equality_comparable<T, CmpType>);
  1833       return value_cref_() == cmp;
  1857   template <
typename ErrCmp>
  1859     static_assert(equality_comparable<E, ErrCmp>);
  1863       return err_cref_() == cmp;
  1881   template <
typename UnaryPredicate>
  1882   [[nodiscard]] constexpr 
bool exists(UnaryPredicate && predicate)
 const {
  1883     static_assert(invocable<UnaryPredicate&&, T const&>);
  1887       return std::forward<UnaryPredicate&&>(predicate)(value_cref_());
  1907   template <
typename UnaryPredicate>
  1908   [[nodiscard]] constexpr 
bool err_exists(UnaryPredicate && predicate)
 const {
  1909     static_assert(invocable<UnaryPredicate&&, E const&>);
  1913       return std::forward<UnaryPredicate&&>(predicate)(err_cref_());
  1939     return value_ref_();
  1959   [[nodiscard]] T 
const& 
value() const& noexcept {
  1961     return value_cref_();
  1965   [[deprecated(
"Use `unwrap()` instead")]] T value()&& = 
delete;
  1967   [[deprecated(
"Use `unwrap()` instead")]] T 
const value() 
const&& = 
delete;
  2015   [[deprecated(
"Use `unwrap_err()` instead")]] E err_value()&& = 
delete;
  2017   [[deprecated(
"Use `unwrap_err()` instead")]] E 
const err_value() 
const&& =
  2036   [[nodiscard]] constexpr 
auto ok()&&->Option<T> {
  2038       return Some<T>(std::move(value_ref_()));
  2060   [[nodiscard]] constexpr 
auto err()&&->Option<E> {
  2064       return Some<E>(std::move(err_ref_()));
  2094       "calling Result::as_cref() on an r-value, and "  2095       "therefore binding an l-value reference to an object that is marked to "  2097   [[nodiscard]] constexpr 
auto  2120   [[nodiscard]] constexpr 
auto as_ref()& noexcept
  2135       "calling Result::as_ref() on an r-value, and therefore binding a "  2136       "reference to an object that is marked to be moved")]]  
  2137   [[nodiscard]] constexpr 
auto  2141       "calling Result::as_ref() on an r-value, and therefore binding a "  2142       "reference to an object that is marked to be moved")]]  
  2143   [[nodiscard]] constexpr 
auto  2144   as_ref() 
const&& noexcept->Result<
ConstRef<T>, ConstRef<E>> = 
delete;
  2171   template <
typename Fn>
  2172   [[nodiscard]] constexpr 
auto map(Fn &&
  2174     static_assert(invocable<Fn&&, T&&>);
  2177           std::forward<Fn&&>(op)(std::move(value_ref_())));
  2179       return Err<E>(std::move(err_ref_()));
  2198   template <
typename Fn, 
typename AltType>
  2200       Fn && op, AltType && alt)&&->invoke_result<Fn&&, T&&> {
  2201     static_assert(invocable<Fn&&, T&&>);
  2203       return std::forward<Fn&&>(op)(std::move(value_ref_()));
  2205       return std::forward<AltType&&>(alt);
  2231   template <
typename Fn, 
typename A>
  2233       Fn && op, A && alt_op)&&->invoke_result<Fn&&, T&&> {
  2234     static_assert(invocable<Fn&&, T&&>);
  2235     static_assert(invocable<A&&, E&&>);
  2238       return std::forward<Fn&&>(op)(std::move(value_ref_()));
  2240       return std::forward<A&&>(alt_op)(std::move(err_ref_()));
  2264   template <
typename Fn>
  2267     static_assert(invocable<Fn&&, E&&>);
  2269       return Ok<T>(std::move(value_ref_()));
  2272           std::forward<Fn&&>(op)(std::move(err_ref_())));
  2301   template <
typename U, 
typename F>
  2303     static_assert(convertible<E&&, F>);
  2305       return std::forward<Result<U, F>&&>(res);
  2307       return Err<F>(std::move(static_cast<F>(std::move(err_ref_()))));
  2329   template <
typename Fn>
  2332     static_assert(invocable<Fn&&, T&&>);
  2335           std::forward<Fn&&>(op)(std::move(value_ref_())));
  2337       return Err<E>(std::move(err_ref_()));
  2370   template <
typename U, 
typename F>
  2372     static_assert(convertible<T&&, U>);
  2374       return Ok<U>(std::move(static_cast<U>(std::move(value_ref_()))));
  2376       return std::forward<Result<U, F>&&>(alt);
  2400   template <
typename Fn>
  2401   [[nodiscard]] constexpr 
auto or_else(Fn && op)&&->invoke_result<Fn&&, E&&> {
  2402     static_assert(invocable<Fn&&, E&&>);
  2404       return Ok<T>(std::move(value_ref_()));
  2406       return std::forward<Fn&&>(op)(std::move(err_ref_()));
  2432       return std::move(value_ref_());
  2434       return std::move(alt);
  2453   template <
typename Fn>
  2455     static_assert(invocable<Fn&&, E&&>);
  2457       return std::move(value_ref_());
  2459       return std::forward<Fn&&>(op)(std::move(err_ref_()));
  2483     return std::move(value_ref_());
  2501   [[nodiscard]] 
auto expect(std::string_view 
const& msg)&&->T {
  2505     return std::move(value_ref_());
  2531     return std::move(err_ref_());
  2552   [[nodiscard]] 
auto expect_err(std::string_view 
const& msg)&&->E {
  2556     return std::move(err_ref_());
  2580     static_assert(std::is_default_constructible_v<T>);
  2582       return std::move(value_ref_());
  2619   template <
typename OkFn, 
typename ErrFn>
  2621       OkFn && ok_fn, ErrFn && err_fn)&&->invoke_result<OkFn&&, T&&> {
  2622     static_assert(invocable<OkFn&&, T&&>);
  2623     static_assert(invocable<ErrFn&&, E&&>);
  2626       return std::forward<OkFn&&>(ok_fn)(std::move(value_ref_()));
  2628       return std::forward<ErrFn&&>(err_fn)(std::move(err_ref_()));
  2632   template <
typename OkFn, 
typename ErrFn>
  2634       OkFn && ok_fn, ErrFn && err_fn)&->invoke_result<OkFn&&, T&> {
  2635     static_assert(invocable<OkFn&&, T&>);
  2636     static_assert(invocable<ErrFn&&, E&>);
  2639       return std::forward<OkFn&&>(ok_fn)(value_ref_());
  2641       return std::forward<ErrFn&&>(err_fn)(err_ref_());
  2645   template <
typename OkFn, 
typename ErrFn>
  2646   [[nodiscard]] constexpr 
auto match(OkFn && ok_fn, ErrFn && err_fn)
  2647       const&->invoke_result<OkFn&&, T 
const&> {
  2648     static_assert(invocable<OkFn&&, T const&>);
  2649     static_assert(invocable<ErrFn&&, E const&>);
  2652       return std::forward<OkFn&&>(ok_fn)(value_cref_());
  2654       return std::forward<ErrFn&&>(err_fn)(err_cref_());
  2669   [[nodiscard]] constexpr 
auto clone() const->Result<T, E> {
  2670     static_assert(copy_constructible<T>);
  2671     static_assert(copy_constructible<E>);
  2674       return Ok<T>(std::move(T(value_cref_())));
  2676       return Err<E>(std::move(E(err_cref_())));
  2688   [[nodiscard]] constexpr T& value_ref_() noexcept { 
return storage_value_; }
  2690   [[nodiscard]] constexpr T 
const& value_cref_() 
const noexcept {
  2691     return storage_value_;
  2694   [[nodiscard]] constexpr E& err_ref_() noexcept { 
return storage_err_; }
  2696   [[nodiscard]] constexpr E 
const& err_cref_() 
const noexcept {
  2697     return storage_err_;
  2700   template <
typename Tp, 
typename Er>
  2703   template <
typename Tp, 
typename Er>
  2707 template <
typename U, 
typename T, 
typename E>
  2710   return result == cmp;
  2713 template <
typename U, 
typename T, 
typename E>
  2716   return result != cmp;
  2719 template <
typename F, 
typename T, 
typename E>
  2722   return result == cmp;
  2725 template <
typename F, 
typename T, 
typename E>
  2728   return result != cmp;
  2766 template <
typename T>
  2768   return Some<T>(std::forward<T>(value));
  2797 template <
typename T>
  2834 template <
typename T, 
typename E>
  2836   return Ok<T>(std::forward<T>(value));
  2869 template <
typename T, 
typename E>
  2871   return Err<E>(std::forward<E>(err));
  2894 template <
typename T>
  2919 template <
typename T>
  2921   return Ok<Ref<T>>(std::forward<T&>(value));
  2944 template <
typename E>
 STX_FORCE_INLINE void no_err(SourceLocation const &location=SourceLocation::current()) noexcept
panic helper for Result<T, E>::unwrap_err() when a value is present 
Definition: panic_helpers.h:110
 
constexpr auto AND(Result< U, F > &&res) &&-> Result< U, F >
Definition: option_result.h:2302
 
E const  & err_value() const &noexcept
Definition: option_result.h:2009
 
STX_FORCE_INLINE void no_value(SourceLocation const &location=SourceLocation::current()) noexcept
panic helper for Option<T>::unwrap() when no value is present 
Definition: panic_helpers.h:57
 
auto unwrap() &&-> T
Definition: option_result.h:2479
 
constexpr auto OR(Result< U, F > &&alt) &&-> Result< U, F >
Definition: option_result.h:2371
 
std::reference_wrapper< std::remove_const_t< std::remove_reference_t< T > >> MutRef
MutRef is an always-mutable Ref 
Definition: common.h:90
 
constexpr bool operator==(Ok< U > const &cmp) const
Definition: option_result.h:265
 
constexpr auto match(SomeFn &&some_fn, NoneFn &&none_fn) &&-> invoke_result< SomeFn &&, T &&>
Definition: option_result.h:1470
 
T & value() &noexcept
Definition: option_result.h:1937
 
constexpr T & value() &noexcept
Definition: option_result.h:183
 
constexpr bool is_none() const noexcept
Definition: option_result.h:602
 
auto expect(std::string_view const &msg) &&-> T
Definition: option_result.h:2501
 
Definition: option_result.h:98
 
constexpr auto and_then(Fn &&op) &&-> Result< invoke_result< Fn &&, T &&>, E >
Definition: option_result.h:2330
 
constexpr bool contains(CmpType const &cmp) const
Definition: option_result.h:1830
 
constexpr auto err() &&-> Option< E >
Definition: option_result.h:2060
 
STX_FORCE_INLINE void no_none(SourceLocation const &location=SourceLocation::current()) noexcept
panic helper for Option<T>::unwrap_none() when a value is present 
Definition: panic_helpers.h:69
 
constexpr bool exists(UnaryPredicate &&predicate) const
Definition: option_result.h:1882
 
constexpr bool operator==(NoneType const &) const noexcept
Definition: option_result.h:565
 
constexpr bool operator!=(Ok< F > const &) const noexcept
Definition: option_result.h:367
 
auto expect_err(std::string_view const &msg) &&-> E
Definition: option_result.h:2552
 
auto unwrap_err() &&-> E
Definition: option_result.h:2527
 
constexpr auto OR(Option &&alt) &&-> Option
Definition: option_result.h:1180
 
constexpr auto unwrap_or_else(Fn &&op) &&-> T
Definition: option_result.h:868
 
STX_FORCE_INLINE constexpr bool operator!=(Err< F > const &cmp, Result< T, E > const &result)
Definition: option_result.h:2726
 
constexpr bool operator==(NoneType const &) const noexcept
Definition: option_result.h:199
 
constexpr auto map_or(Fn &&op, AltType &&alt) &&-> invoke_result< Fn &&, T &&>
Definition: option_result.h:2199
 
constexpr bool exists(UnaryPredicate &&predicate) const
Definition: option_result.h:647
 
T storage_value_
Definition: option_result.h:1510
 
constexpr auto AND(Option< U > &&cmp) &&-> Option< U >
Definition: option_result.h:1052
 
STX_FORCE_INLINE void no_lref(SourceLocation const &location=SourceLocation::current()) noexcept
panic helper for Option<T>::value() when no value is present 
Definition: panic_helpers.h:63
 
constexpr bool operator!=(Some< U > const &cmp) const
Definition: option_result.h:194
 
constexpr auto ok() &&-> Option< T >
Definition: option_result.h:2036
 
std::reference_wrapper< std::add_const_t< std::remove_reference_t< T > >> ConstRef
ConstRef is an always-const Ref. 
Definition: common.h:85
 
constexpr bool operator==(Err< F > const &cmp) const
Definition: option_result.h:350
 
constexpr bool operator==(Some< U > const &cmp) const
Definition: option_result.h:546
 
auto expect(std::string_view const &msg) &&-> T
Definition: option_result.h:793
 
constexpr T value() &&
Definition: option_result.h:185
 
E error_type
Definition: option_result.h:1659
 
constexpr auto unwrap_or_else(Fn &&op) &&-> T
Definition: option_result.h:2454
 
constexpr bool operator!=(Result< U, F > const &cmp) const
Definition: option_result.h:1765
 
constexpr E const value() const &&
Definition: option_result.h:373
 
constexpr bool operator==(Result< U, F > const &cmp) const
Definition: option_result.h:1751
 
constexpr auto map(Fn &&op) &&-> Result< invoke_result< Fn &&, T &&>, E >
Definition: option_result.h:2172
 
STX_FORCE_INLINE constexpr auto make_some(T value) -> Option< T >
Definition: option_result.h:2767
 
constexpr auto as_cref() const &noexcept -> Result< ConstRef< T >, ConstRef< E >>
Definition: option_result.h:2084
 
constexpr auto match(OkFn &&ok_fn, ErrFn &&err_fn) const &-> invoke_result< OkFn &&, T const &>
Definition: option_result.h:2646
 
constexpr auto as_ref() const &noexcept -> Option< ConstRef< T >>
Definition: option_result.h:756
 
constexpr bool is_ok() const noexcept
Definition: option_result.h:1792
 
T value_type
Definition: option_result.h:170
 
STX_FORCE_INLINE constexpr bool operator==(Err< F > const &cmp, Result< T, E > const &result)
Definition: option_result.h:2720
 
constexpr T const  & value() const &noexcept
Definition: option_result.h:182
 
constexpr auto unwrap_or_default() &&-> T
Definition: option_result.h:2579
 
constexpr T & value() &noexcept
Definition: option_result.h:287
 
STX_FORCE_INLINE void expect_value_failed(std::string_view const &msg, SourceLocation const &location=SourceLocation::current()) noexcept
panic helper for Option<T>::expect() when no value is present 
Definition: panic_helpers.h:43
 
void unwrap_none() &&
Definition: option_result.h:1408
 
constexpr bool operator!=(Err< F > const &cmp) const
Definition: option_result.h:1741
 
constexpr auto map_or_else(Fn &&op, AltFn &&alt) &&-> invoke_result< Fn &&, T &&>
Definition: option_result.h:956
 
constexpr bool operator==(Some< U > const &cmp) const
Definition: option_result.h:188
 
constexpr auto XOR(Option &&alt) &&-> Option
Definition: option_result.h:1239
 
constexpr E const  & value() const &noexcept
Definition: option_result.h:371
 
constexpr bool operator!=(NoneType const &) const noexcept
Definition: option_result.h:569
 
constexpr auto match(SomeFn &&some_fn, NoneFn &&none_fn) &-> invoke_result< SomeFn &&, T &>
Definition: option_result.h:1483
 
constexpr bool operator!=(Err< F > const &cmp) const
Definition: option_result.h:356
 
constexpr bool operator==(Ok< F > const &) const noexcept
Definition: option_result.h:362
 
constexpr T value() &&
Definition: option_result.h:289
 
Tp && unsafe_value_move(Result< Tp, Er > &)
 
constexpr E value() &&
Definition: option_result.h:374
 
constexpr auto filter(UnaryPredicate &&predicate) &&-> Option
Definition: option_result.h:1108
 
Option & operator=(Option &&rhs)
Definition: option_result.h:472
 
#define STX_FORCE_INLINE
Definition: config.h:254
 
constexpr bool err_exists(UnaryPredicate &&predicate) const
Definition: option_result.h:1908
 
constexpr Option(Some< T > const &some)
Definition: option_result.h:456
 
Result(Result &&rhs)
Definition: option_result.h:1671
 
auto replace(T &&replacement) -> Option
Definition: option_result.h:1298
 
constexpr auto map_or(Fn &&op, A &&alt) &&-> invoke_result< Fn &&, T &&>
Definition: option_result.h:927
 
Definition: option_result.h:81
 
Definition: option_result.h:76
 
constexpr bool operator==(Option< U > const &cmp) const
Definition: option_result.h:522
 
constexpr auto unwrap_or(T &&alt) &&-> T
Definition: option_result.h:846
 
constexpr Some(T &&value)
a Some<T> can only be constructed with an r-value of type T 
Definition: option_result.h:173
 
constexpr NoneType const None
value-variant for Option<T> representing no-value 
Definition: option_result.h:127
 
Definition: option_result.h:90
 
constexpr auto map(Fn &&op) &&-> Option< invoke_result< Fn &&, T &&>>
Definition: option_result.h:900
 
constexpr auto ok_or_else(Fn &&op) &&-> Result< T, invoke_result< Fn &&>>
Definition: option_result.h:1015
 
Definition: option_result.h:84
 
void expect_none(std::string_view const &msg) &&
Definition: option_result.h:1382
 
constexpr bool operator!=(Some< U > const &cmp) const
Definition: option_result.h:556
 
STX_FORCE_INLINE auto ok_ref(T &value) noexcept
Definition: option_result.h:2920
 
constexpr bool operator==(Ok< U > const &cmp) const
Definition: option_result.h:1711
 
Definition: option_result.h:87
 
constexpr T const  & value() const &noexcept
Definition: option_result.h:286
 
constexpr bool convertible
Definition: common.h:53
 
Option(Option &&rhs)
Definition: option_result.h:466
 
constexpr T const value() const &&
Definition: option_result.h:288
 
STX_FORCE_INLINE constexpr auto make_err(E err) -> Result< T, E >
Definition: option_result.h:2870
 
Option(Option const &rhs)
Definition: option_result.h:492
 
#define STX_CXX20_DESTRUCTOR_CONSTEXPR
Definition: config.h:231
 
E value_type
Definition: option_result.h:337
 
STX_FORCE_INLINE constexpr auto make_none() noexcept -> Option< T >
Definition: option_result.h:2798
 
T storage_value_
Definition: option_result.h:2682
 
constexpr auto take() -> Option
Definition: option_result.h:1267
 
constexpr bool operator==(NoneType const &) const noexcept
Definition: option_result.h:107
 
constexpr Ok(T &&value)
an Ok<T> can only be constructed with an r-value of type T 
Definition: option_result.h:255
 
STX_FORCE_INLINE void expect_err_failed(std::string_view const &msg, SourceLocation const &location=SourceLocation::current()) noexcept
panic helper for Result<T, E>::expect_err() when a value is present 
Definition: panic_helpers.h:87
 
constexpr auto and_then(Fn &&op) &&-> invoke_result< Fn &&, T &&>
Definition: option_result.h:1079
 
constexpr auto clone() const -> Option
Definition: option_result.h:1353
 
constexpr bool operator==(Err< U > const &) const noexcept
Definition: option_result.h:277
 
constexpr auto unwrap_or_default() &&-> T
Definition: option_result.h:1432
 
STX_FORCE_INLINE auto some_ref(T &value) noexcept
Definition: option_result.h:2895
 
constexpr Option(Some< T > &&some)
Definition: option_result.h:453
 
uintptr_t value_type
Definition: option_result.h:441
 
STX_CXX20_DESTRUCTOR_CONSTEXPR ~Result() noexcept
Definition: option_result.h:1702
 
constexpr bool operator!=(Some< T > const &) const noexcept
Definition: option_result.h:121
 
Er && unsafe_err_move(Result< Tp, Er > &)
 
STX_FORCE_INLINE void no_err_lref(SourceLocation const &location=SourceLocation::current()) noexcept
panic helper for Result<T, E>::err_value() when no value is present 
Definition: panic_helpers.h:116
 
STX_FORCE_INLINE void expect_none_failed(std::string_view const &msg, SourceLocation const &location=SourceLocation::current()) noexcept
panic helper for Option<T>::expect_none() when a value is present 
Definition: panic_helpers.h:50
 
constexpr Option() noexcept
Definition: option_result.h:451
 
T const  & value() const &noexcept
Definition: option_result.h:1959
 
constexpr auto clone() const -> Result< T, E >
Definition: option_result.h:2669
 
constexpr auto filter_not(UnaryPredicate &&predicate) &&-> Option
Definition: option_result.h:1139
 
typename std::invoke_result_t< Fn, Args... > invoke_result
Definition: common.h:40
 
#define STX_END_NAMESPACE
Definition: config.h:329
 
constexpr bool operator!=(Err< U > const &) const noexcept
Definition: option_result.h:282
 
STX_FORCE_INLINE constexpr auto make_ok(T value) -> Result< T, E >
Definition: option_result.h:2835
 
STX_CXX20_DESTRUCTOR_CONSTEXPR ~Option() noexcept
Definition: option_result.h:515
 
constexpr bool operator==(Some< T > const &) const noexcept
Definition: option_result.h:116
 
constexpr auto as_ref() const &noexcept -> Result< ConstRef< T >, ConstRef< E >>
Definition: option_result.h:2129
 
T const  & value() const &noexcept
Definition: option_result.h:698
 
constexpr auto as_ref() &noexcept -> Option< MutRef< T >>
Definition: option_result.h:748
 
constexpr T const value() const &&
Definition: option_result.h:184
 
T value_type
Definition: option_result.h:1658
 
T value_type
Definition: option_result.h:252
 
constexpr Result(Err< E > &&err)
Definition: option_result.h:1664
 
constexpr Err(E &&value)
an Err<E> can only be constructed with an r-value of type E 
Definition: option_result.h:340
 
constexpr auto as_ref() &noexcept -> Result< MutRef< T >, MutRef< E >>
Definition: option_result.h:2120
 
constexpr bool operator!=(NoneType const &) const noexcept
Definition: option_result.h:203
 
constexpr Result(Ok< T > &&result)
Definition: option_result.h:1661
 
constexpr bool operator!=(Option< U > const &cmp) const
Definition: option_result.h:534
 
STX_FORCE_INLINE auto err_ref(E &value) noexcept
Definition: option_result.h:2945
 
constexpr bool contains(CmpType const &cmp) const
Definition: option_result.h:624
 
auto replace(T const &replacement) -> Option
Definition: option_result.h:1329
 
constexpr auto match(OkFn &&ok_fn, ErrFn &&err_fn) &-> invoke_result< OkFn &&, T &>
Definition: option_result.h:2633
 
constexpr auto match(OkFn &&ok_fn, ErrFn &&err_fn) &&-> invoke_result< OkFn &&, T &&>
Definition: option_result.h:2620
 
E storage_err_
Definition: option_result.h:2683
 
constexpr auto map_err(Fn &&op) &&-> Result< T, invoke_result< Fn &&, E &&>>
Definition: option_result.h:2265
 
T & value() &noexcept
Definition: option_result.h:676
 
constexpr E & value() &noexcept
Definition: option_result.h:372
 
constexpr bool operator!=(Ok< U > const &cmp) const
Definition: option_result.h:1721
 
#define STX_BEGIN_NAMESPACE
Definition: config.h:325
 
constexpr bool is_err() const noexcept
Definition: option_result.h:1807
 
constexpr auto as_cref() const &noexcept -> Option< ConstRef< T >>
Definition: option_result.h:714
 
constexpr auto match(SomeFn &&some_fn, NoneFn &&none_fn) const &-> invoke_result< SomeFn &&, T const &>
Definition: option_result.h:1496
 
auto unwrap() &&-> T
Definition: option_result.h:823
 
constexpr bool is_some() const noexcept
Definition: option_result.h:587
 
constexpr bool operator!=(Ok< U > const &cmp) const
Definition: option_result.h:271
 
E & err_value() &noexcept
Definition: option_result.h:1987
 
constexpr Option(NoneType const &) noexcept
Definition: option_result.h:461
 
constexpr auto or_else(Fn &&op) &&-> Option
Definition: option_result.h:1205
 
Result & operator=(Result &&rhs)
Definition: option_result.h:1679
 
constexpr bool operator==(Err< F > const &cmp) const
Definition: option_result.h:1731
 
constexpr auto ok_or(E error) &&-> Result< T, E >
Definition: option_result.h:988
 
constexpr bool operator!=(NoneType const &) const noexcept
Definition: option_result.h:111
 
constexpr auto map_or_else(Fn &&op, A &&alt_op) &&-> invoke_result< Fn &&, T &&>
Definition: option_result.h:2232
 
constexpr bool contains_err(ErrCmp const &cmp) const
Definition: option_result.h:1858
 
Option & operator=(Option const &rhs)
Definition: option_result.h:499
 
constexpr auto unwrap_or(T &&alt) &&-> T
Definition: option_result.h:2430
 
constexpr auto or_else(Fn &&op) &&-> invoke_result< Fn &&, E &&>
Definition: option_result.h:2401