Fix handling of volatile char (#1115)
This commit is contained in:
parent
bade46aae5
commit
5d755d0a4e
@ -872,11 +872,12 @@ inline init<C, basic_string_view<Char>, string_type> make_value(const T& val) {
|
||||
// unsafe: https://github.com/fmtlib/fmt/issues/729
|
||||
template <
|
||||
typename C, typename T, typename Char = typename C::char_type,
|
||||
FMT_ENABLE_IF(!convert_to_int<T, Char>::value &&
|
||||
!std::is_same<T, Char>::value &&
|
||||
!std::is_convertible<T, basic_string_view<Char>>::value &&
|
||||
!is_constructible<basic_string_view<Char>, T>::value &&
|
||||
!internal::is_string<T>::value)>
|
||||
typename U = typename std::remove_volatile<T>::type,
|
||||
FMT_ENABLE_IF(!convert_to_int<U, Char>::value &&
|
||||
!std::is_same<U, Char>::value &&
|
||||
!std::is_convertible<U, basic_string_view<Char>>::value &&
|
||||
!is_constructible<basic_string_view<Char>, U>::value &&
|
||||
!internal::is_string<U>::value)>
|
||||
inline init<C, const T&, custom_type> make_value(const T& val) {
|
||||
return val;
|
||||
}
|
||||
|
@ -1550,6 +1550,11 @@ TEST(FormatterTest, FormatChar) {
|
||||
EXPECT_EQ(fmt::format("{:02X}", n), fmt::format("{:02X}", 'x'));
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatVolatileChar) {
|
||||
volatile char c = 'x';
|
||||
EXPECT_EQ("x", format("{}", c));
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatUnsignedChar) {
|
||||
EXPECT_EQ("42", format("{}", static_cast<unsigned char>(42)));
|
||||
EXPECT_EQ("42", format("{}", static_cast<uint8_t>(42)));
|
||||
|
Loading…
Reference in New Issue
Block a user