This commit is contained in:
Timur A. Fatkhullin
2024-01-23 23:30:48 +03:00
parent fa0cfea8fe
commit 969429d2f6
2 changed files with 78 additions and 15 deletions

View File

@@ -1,9 +1,9 @@
#pragma once
#include <format>
#include <ranges>
#include <tuple>
#include <type_traits>
#include <format>
/*
@@ -17,16 +17,28 @@ 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);
};
// (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, 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>;
concept adc_char_range =
std::ranges::range<R> && std::is_same_v<std::remove_cv_t<std::ranges::range_value_t<R>>, CharT>;
// output range of char/const char
template <typename R, typename CharT = char>
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>;
// deduce returned type of callable
template <typename T>