1#ifndef CAPYMETA_STATIC_EITHER_HPP_
2#define CAPYMETA_STATIC_EITHER_HPP_
20template<
typename Value,
typename Error,
typename Tag>
23template<
typename Value,
typename Error>
32 : value_ { std::move(
value) }
41 template<
typename Self>
42 constexpr decltype(
auto)
value(
this Self&& self)
44 return std::forward<Self>(self).value_;
47 template<
typename Self>
48 constexpr decltype(
auto)
error(
this Self&& self)
52 "Trying to extract an error while the either-object contains value"
58 return std::expected { std::move(this->value_) };
62 static constexpr bool HAS_VALUE =
true;
68template<
typename Value,
typename Error>
77 : error_ { std::move(
error) }
86 template<
typename Self>
87 constexpr decltype(
auto)
value(
this Self&& self)
89 static_assert(
false,
"Trying to retrieve value from error either-object");
92 template<
typename Self>
93 constexpr decltype(
auto)
error(
this Self&& self)
95 return std::forward<Self>(self).error_;
100 return std::unexpected { std::move(this->error_) };
104 static constexpr bool HAS_VALUE =
false;
110template<
typename Value,
typename Error>
113template<
typename Value,
typename Error>