serializing/deserializing functions
This commit is contained in:
@@ -21,7 +21,7 @@ namespace adc::traits
|
||||
// https://stackoverflow.com/questions/72430369/how-to-check-that-a-type-is-formattable-using-type-traits-concepts)
|
||||
template <typename T>
|
||||
concept formattable =
|
||||
requires(T& v, std::format_context ctx) { std::formatter<std::remove_cvref_t<T>>().format(v, ctx); };
|
||||
requires(T v, std::format_context ctx) { std::formatter<std::remove_cvref_t<T>>().format(v, ctx); };
|
||||
|
||||
|
||||
// range of char/const char
|
||||
@@ -37,7 +37,8 @@ concept adc_output_char_range = std::ranges::output_range<R, CharT>;
|
||||
|
||||
// range of char/const char
|
||||
template <typename R, typename CharT = char>
|
||||
concept adc_input_char_range = std::ranges::input_range<CharT>;
|
||||
concept adc_input_char_range = std::ranges::input_range<R>;
|
||||
// concept adc_input_char_range = std::ranges::input_range<CharT>;
|
||||
|
||||
|
||||
// deduce returned type of callable
|
||||
@@ -106,4 +107,28 @@ constexpr static auto adc_pf_wrapper(T&& v, Ts&&... vs)
|
||||
}
|
||||
|
||||
|
||||
// check if type T is one of types in sequence Rest (e.g. adc_is_any<int,char,float,int,std::string>::value == true)
|
||||
|
||||
template <typename T, typename... Rest>
|
||||
struct adc_is_any_of : std::disjunction<std::is_same<T, Rest>...> {
|
||||
};
|
||||
|
||||
template <typename T, typename... Rest>
|
||||
static inline constexpr bool adc_is_any_of_v = std::disjunction_v<std::is_same<T, Rest>...>;
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct adc_is_tuple : std::false_type {
|
||||
};
|
||||
|
||||
|
||||
template <typename... Ts>
|
||||
struct adc_is_tuple<std::tuple<Ts...>> : std::true_type {
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
static inline constexpr bool adc_is_tuple_v = adc_is_tuple<T>::value;
|
||||
|
||||
} // namespace adc::traits
|
||||
|
||||
Reference in New Issue
Block a user