Added formattable concept (#3974)

This commit is contained in:
Matthias Moulin
2024-05-26 16:47:56 +02:00
committed by GitHub
parent 1768bf9714
commit 1752d7fbbb
2 changed files with 84 additions and 0 deletions

View File

@@ -149,6 +149,15 @@ import std;
# define FMT_USE_NONTYPE_TEMPLATE_ARGS 0
#endif
// Detect C++20 concepts
#ifdef FMT_USE_CONCEPTS
// Use the provided definition.
#elif defined(__cpp_concepts)
# define FMT_USE_CONCEPTS 1
#else
# define FMT_USE_CONCEPTS 0
#endif
// Check if exceptions are disabled.
#ifdef FMT_EXCEPTIONS
// Use the provided definition.
@@ -2007,6 +2016,11 @@ using is_formattable = bool_constant<!std::is_base_of<
detail::unformattable, decltype(detail::arg_mapper<buffered_context<Char>>()
.map(std::declval<T&>()))>::value>;
#if FMT_USE_CONCEPTS
template <typename T, typename Char = char>
concept formattable = is_formattable<remove_reference_t<T>, Char>::value;
#endif
/**
\rst
Constructs an object that stores references to arguments and can be implicitly