12#include "sygah-consteval.hpp"
27 std::decay_t<T>::range().min;
28 std::decay_t<T>::range().max;
29 std::decay_t<T>::range().init;
33constexpr auto get_range(
const T&) {
return T::range(); }
36_consteval
auto get_range() {
return std::decay_t<T>::range(); }
37template <
typename T,
typename Y>
39 =
requires (T t) {
static_cast<Y
>(t); }
40 &&
requires (Y y) { T{y}; }
41 &&
requires (T t, Y y) { t = y; }
42 &&
requires (T a, T b, Y c) { a = b = c; }
45template<
typename T,
typename Y>
64 && std::default_initializable<std::remove_cvref_t<T>>;
76 requires std::same_as<bool,
decltype(t.updated)>;
92concept Bang =
requires (T t)
94 requires std::is_enum_v<
decltype(T::bang)>;
99template<ClearableFlag T>
100constexpr void clear_flag(T& t)
106template<ClearableFlag T>
107constexpr bool flag_state_of(T& t)
113template<ClearableFlag T>
114constexpr void set_flag(T& t)
116 if constexpr (UpdatedFlag<T>) t.updated =
true;
117 else if constexpr (BoolishFlag<T>) t =
true;
123template <has_value T>
142const auto& value_of(
const T& v)
144 return value_of(
const_cast<T&
>(v));
147template <has_value T>
148auto& set_value(T& v,
const auto& arg)
150 if constexpr (
requires {value_of(v).fill(arg);})
152 value_of(v).fill(arg);
153 if constexpr (ClearableFlag<T>) set_flag(v);
159using value_t = std::remove_cvref_t<decltype(value_of(std::declval<T&>()))>;
161template<
typename T>
concept string_like =
requires (T t,
const char * s)
170} && std::same_as<std::remove_cvref_t<
decltype(std::tuple_size_v<T>)>, std::size_t>;
172template<array_like T>
173_consteval
auto size()
175 return std::tuple_size_v<T>;
182 using type = std::remove_cvref_t<decltype(std::declval<T>()[0])>;
186template<has_value T>
using element_t =
typename _element_type<T>::type;
187#define tagged(TAG) template<typename T> concept tagged_##TAG\
188 = std::is_enum_v<decltype(T::TAG)>\
189 || std::is_enum_v<typename T::TAG>
194void initialize_endpoint(T& ep)
196 if constexpr (not has_range<T>)
return;
197 else set_value(ep, get_range(ep).init);
Definition sygac-endpoints.hpp:92
Definition sygac-endpoints.hpp:66
Definition sygac-endpoints.hpp:97
Definition sygac-endpoints.hpp:79
Definition sygac-endpoints.hpp:90
Definition sygac-endpoints.hpp:63
Definition sygac-endpoints.hpp:73
Definition sygac-endpoints.hpp:82
Definition sygac-endpoints.hpp:166
Definition sygac-endpoints.hpp:25
Definition sygac-endpoints.hpp:55
Definition sygac-endpoints.hpp:48
Definition sygac-endpoints.hpp:121
Definition sygac-endpoints.hpp:46
Definition sygac-endpoints.hpp:39
Definition sygac-endpoints.hpp:161
Definition sygac-endpoints.hpp:178