mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-27 03:21:34 +00:00
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
|
// unsafe: https://github.com/fmtlib/fmt/issues/729
|
||||||
template <
|
template <
|
||||||
typename C, typename T, typename Char = typename C::char_type,
|
typename C, typename T, typename Char = typename C::char_type,
|
||||||
FMT_ENABLE_IF(!convert_to_int<T, Char>::value &&
|
typename U = typename std::remove_volatile<T>::type,
|
||||||
!std::is_same<T, Char>::value &&
|
FMT_ENABLE_IF(!convert_to_int<U, Char>::value &&
|
||||||
!std::is_convertible<T, basic_string_view<Char>>::value &&
|
!std::is_same<U, Char>::value &&
|
||||||
!is_constructible<basic_string_view<Char>, T>::value &&
|
!std::is_convertible<U, basic_string_view<Char>>::value &&
|
||||||
!internal::is_string<T>::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) {
|
inline init<C, const T&, custom_type> make_value(const T& val) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -1550,6 +1550,11 @@ TEST(FormatterTest, FormatChar) {
|
|||||||
EXPECT_EQ(fmt::format("{:02X}", n), fmt::format("{:02X}", 'x'));
|
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) {
|
TEST(FormatterTest, FormatUnsignedChar) {
|
||||||
EXPECT_EQ("42", format("{}", static_cast<unsigned char>(42)));
|
EXPECT_EQ("42", format("{}", static_cast<unsigned char>(42)));
|
||||||
EXPECT_EQ("42", format("{}", static_cast<uint8_t>(42)));
|
EXPECT_EQ("42", format("{}", static_cast<uint8_t>(42)));
|
||||||
|
Loading…
Reference in New Issue
Block a user