38 typedef signed char repr_t;
39 enum value_t : repr_t { no_value = -1, maybe_value = 0, yes_value = 1 };
48 constexpr trival(
bool v)
49 : val_(v ? yes_value : no_value)
56 static trival from_repr_t(repr_t v)
58 return trival(static_cast<value_t>(v));
62 constexpr
explicit trival(value_t v)
67 static constexpr trival maybe() noexcept
75 return val_ != maybe_value;
78 constexpr
bool is_maybe()
const 80 return val_ == maybe_value;
83 constexpr
bool is_true()
const 85 return val_ == yes_value;
88 constexpr
bool is_false()
const 90 return val_ == no_value;
93 constexpr value_t val()
const 102 explicit operator bool()
const 104 return val_ == yes_value;
107 constexpr trival operator!()
const 109 return trival((val_ == yes_value) ? no_value :
110 (val_ == no_value) ? yes_value :
125 return a.val() == b.val();
137 (a.val() == trival::no_value || b.val() == trival::no_value)
139 : (a.val() == trival::maybe_value || b.val() == trival::maybe_value)
157 (a.val() == trival::yes_value || b.val() == trival::yes_value)
159 : (a.val() == trival::maybe_value || b.val() == trival::maybe_value)
174 inline std::ostream& operator<<(std::ostream& os,
trival v)
176 return os << ((v.val() == trival::no_value) ?
"no" 177 : (v.val() == trival::maybe_value) ?
"maybe" Definition: automata.hh:26
constexpr bool is_known() const
Is true or false, but not maybe.
Definition: trival.hh:73
A class implementing Kleene's three-valued logic.
Definition: trival.hh:33