Fix std::byte formatting with compile-time API (#2072)
* add test for byte formatting with `FMT_COMPILE` * fix byte formatting with `FMT_COMPILE`, use `__cpp_lib_byte` macro * use is not custom mapped type check * workaround MSVC bug
This commit is contained in:
@@ -2113,9 +2113,14 @@ FMT_CONSTEXPR OutputIt write(OutputIt out, T value) {
|
||||
return base_iterator(out, it);
|
||||
}
|
||||
|
||||
template <typename Char, typename OutputIt, typename T,
|
||||
FMT_ENABLE_IF(std::is_enum<T>::value &&
|
||||
!std::is_same<T, Char>::value)>
|
||||
// FMT_ENABLE_IF() condition separated to workaround MSVC bug
|
||||
template <
|
||||
typename Char, typename OutputIt, typename T,
|
||||
bool check =
|
||||
std::is_enum<T>::value && !std::is_same<T, Char>::value &&
|
||||
mapped_type_constant<T, basic_format_context<OutputIt, Char>>::value !=
|
||||
type::custom_type,
|
||||
FMT_ENABLE_IF(check)>
|
||||
FMT_CONSTEXPR OutputIt write(OutputIt out, T value) {
|
||||
return write<Char>(
|
||||
out, static_cast<typename std::underlying_type<T>::type>(value));
|
||||
@@ -3570,7 +3575,7 @@ 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::std_string_view<Char>, basic_string_view<Char>);
|
||||
#if __cplusplus >= 201703L
|
||||
#ifdef __cpp_lib_byte
|
||||
FMT_FORMAT_AS(std::byte, unsigned);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user