Skip to content

Commit

Permalink
Added formattable concept
Browse files Browse the repository at this point in the history
  • Loading branch information
matt77hias committed May 25, 2024
1 parent b817610 commit 4504060
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4504060

Please sign in to comment.