Enable format_as for classes

This commit is contained in:
Victor Zverovich
2023-01-03 08:58:23 -08:00
parent b7535365b2
commit 9121f9b1d3
2 changed files with 11 additions and 1 deletions
+6
View File
@@ -1348,10 +1348,16 @@ inline auto format_as(std::byte b) -> unsigned char {
}
#endif
template <typename T> struct convertible_to { operator const T&() const; };
template <typename T> struct has_format_as {
template <typename U, typename V = decltype(format_as(U())),
FMT_ENABLE_IF(std::is_enum<U>::value)>
static auto check(U*) -> std::true_type;
// Use convertible_to to avoid implicit conversions.
template <typename U, typename V = decltype(format_as(convertible_to<U>())),
FMT_ENABLE_IF(std::is_class<U>::value)>
static auto check(U*) -> std::true_type;
static auto check(...) -> std::false_type;
enum { value = decltype(check(static_cast<T*>(nullptr)))::value };