mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-26 18:28:20 +00:00
fix formatter<char*> (#3432)
This commit is contained in:
parent
d60b907f87
commit
08ef0d0842
@ -2694,7 +2694,7 @@ struct formatter<T, Char,
|
||||
template <typename Char> \
|
||||
struct formatter<Type, Char> : formatter<Base, Char> { \
|
||||
template <typename FormatContext> \
|
||||
auto format(const Type& val, FormatContext& ctx) const \
|
||||
auto format(Type const& val, FormatContext& ctx) const \
|
||||
-> decltype(ctx.out()) { \
|
||||
return formatter<Base, Char>::format(static_cast<Base>(val), ctx); \
|
||||
} \
|
||||
|
@ -2245,3 +2245,19 @@ TEST(format_test, format_named_arg_with_locale) {
|
||||
}
|
||||
|
||||
#endif // FMT_STATIC_THOUSANDS_SEPARATOR
|
||||
|
||||
struct convertible_to_nonconst_cstring {
|
||||
operator char*() const {
|
||||
static char c[]="bar";
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
template <> struct formatter<convertible_to_nonconst_cstring> : formatter<char*> {
|
||||
};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
TEST(format_test, formatter_nonconst_char) {
|
||||
EXPECT_EQ(fmt::format("{}", convertible_to_nonconst_cstring()), "bar");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user