This commit is contained in:
2024-01-22 00:34:49 +03:00
parent 41a9c70e70
commit fa0cfea8fe
2 changed files with 60 additions and 52 deletions

View File

@@ -3,6 +3,7 @@
#include <ranges>
#include <tuple>
#include <type_traits>
#include <format>
/*
@@ -15,9 +16,17 @@
namespace adc::traits
{
// check if type can be used with std::format_to
// (from 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);
};
// range of char/const char
template <typename R>
concept adc_char_range = std::ranges::range<R> && std::is_same_v<std::remove_cv_t<std::ranges::range_value_t<R>>, char>;
template <typename R, typename CharT = char>
concept adc_char_range = std::ranges::range<R> && std::is_same_v<std::remove_cv_t<std::ranges::range_value_t<R>>, CharT>;
// deduce returned type of callable
template <typename T>