17 #include <type_traits>
23 template<
class T,
class char_t>
24 concept formattable_c =
requires(T& value, std::basic_format_context<std::add_pointer_t<char_t>, char_t>& ctx) {
25 std::formatter<T, char_t>().format(value, ctx);
30 template<
class char_t,
class... args_t>
33 template<
class context_t>
34 constexpr
auto format(
const std::variant<args_t...>& variant, context_t& ctx)
const
37 [&ctx]<
class T>(
const T& value)
39 if constexpr (qx::formattable_c<T, char_t>)
40 return std::format_to(ctx.out(),
QX_STR_PREFIX(char_t,
"{}"), value);
42 QX_STATIC_ASSERT_NO_INSTANTIATION(
"No formatter for this type");
requires(same_variadic_args_v< args_t... >) const expr auto coalesce(args_t &&... args)
Coalesce function, C# a ?? b analogue.
#define QX_STR_PREFIX(value_t, str)
Chose witch of prefixes add to string : L or none.