15 template<
typename T, T Sentinel>
24 template<
class U = std::remove_cv_t<T>>
25 requires std::constructible_from<T, U&&>
36 explicit constexpr operator bool ()
const {
return value_ != Sentinel; }
38 constexpr const T&
operator*() const& noexcept {
return value_; }
40 constexpr const T&&
operator*() const&& noexcept {
return std::move(value_); }
41 constexpr T&&
operator*() &&
noexcept {
return std::move(value_); }
42 constexpr const T&
value() const& {
return *
this ? value_ :
throw std::bad_optional_access{}; }
43 constexpr T&
value() & {
return *
this ? value_ :
throw std::bad_optional_access{}; }
44 constexpr const T&&
value() const&& {
return *
this ? std::move(value_) :
throw std::bad_optional_access{}; }
45 constexpr T&&
value() && {
return *
this ? std::move(value_) :
throw std::bad_optional_access{}; }
51 template<
typename T, T Sentinel>
54 return lhs << std::format(
"{}", rhs);
58template<
typename T, T Sentinel>
59struct std::formatter<
osc::ValueOrSentinel<T, Sentinel>> {
60 template<
class ParseCtx>
61 constexpr auto parse(ParseCtx& ctx) {
return inner_.parse(ctx); }
63 template<
class FmtCtx>
66 auto it = std::ranges::copy(std::string_view{
"ValueOrSentinel("}, ctx.out()).out;
67 it = inner_.format(*v, ctx);
72 std::formatter<T> inner_;
Definition value_or_sentinel.h:16
T value_type
Definition value_or_sentinel.h:18
constexpr const T & value() const &
Definition value_or_sentinel.h:42
constexpr T && operator*() &&noexcept
Definition value_or_sentinel.h:41
static constexpr T sentinel()
Definition value_or_sentinel.h:20
constexpr T & value() &
Definition value_or_sentinel.h:43
friend constexpr bool operator==(ValueOrSentinel, ValueOrSentinel)=default
constexpr const T && value() const &&
Definition value_or_sentinel.h:44
constexpr const T && operator*() const &&noexcept
Definition value_or_sentinel.h:40
friend constexpr bool operator==(const ValueOrSentinel &lhs, const U &rhs)
Definition value_or_sentinel.h:31
constexpr T & operator*() &noexcept
Definition value_or_sentinel.h:39
constexpr const T & operator*() const &noexcept
Definition value_or_sentinel.h:38
constexpr ValueOrSentinel()=default
constexpr T && value() &&
Definition value_or_sentinel.h:45
friend constexpr bool operator==(const U &lhs, const ValueOrSentinel &rhs)
Definition value_or_sentinel.h:34
constexpr ValueOrSentinel(U &&value)
Definition value_or_sentinel.h:26
Definition custom_decoration_generator.h:5
std::ostream & operator<<(std::ostream &, const Object &)