Don't convert scoped enums to integers

This commit is contained in:
Victor Zverovich
2021-12-09 12:09:33 -08:00
parent c652f8243a
commit fd62fba985
4 changed files with 15 additions and 1 deletions
+10
View File
@@ -8,6 +8,7 @@
#ifndef FMT_CORE_H_
#define FMT_CORE_H_
#include <cstddef> // std::byte
#include <cstdio> // std::FILE
#include <cstring>
#include <iterator>
@@ -367,6 +368,12 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
# endif
#endif
#ifdef __cpp_lib_byte
using byte = std::byte;
#else
enum class byte : unsigned char {};
#endif
#if defined(FMT_USE_STRING_VIEW)
template <typename Char> using std_string_view = std::basic_string_view<Char>;
#elif defined(FMT_USE_EXPERIMENTAL_STRING_VIEW)
@@ -1403,6 +1410,9 @@ template <typename Context> struct arg_mapper {
template <typename T,
FMT_ENABLE_IF(std::is_enum<T>::value &&
(std::is_convertible<T, int>::value
|| std::is_same<T, detail::byte>::value
) &&
!has_formatter<T, Context>::value &&
!has_fallback_formatter<T, char_type>::value)>
FMT_CONSTEXPR FMT_INLINE auto map(const T& val)
+1
View File
@@ -2606,6 +2606,7 @@ FMT_FORMAT_AS(unsigned long, unsigned long long);
FMT_FORMAT_AS(Char*, const Char*);
FMT_FORMAT_AS(std::basic_string<Char>, basic_string_view<Char>);
FMT_FORMAT_AS(std::nullptr_t, const void*);
FMT_FORMAT_AS(detail::byte, unsigned char);
FMT_FORMAT_AS(detail::std_string_view<Char>, basic_string_view<Char>);
template <typename Char>