mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Fix handling of types with deleted rvalue conversion to string (#1421)
This commit is contained in:
@ -923,7 +923,7 @@ template <typename Context> struct arg_mapper {
|
|||||||
// A type constant after applying arg_mapper<Context>.
|
// A type constant after applying arg_mapper<Context>.
|
||||||
template <typename T, typename Context>
|
template <typename T, typename Context>
|
||||||
using mapped_type_constant =
|
using mapped_type_constant =
|
||||||
type_constant<decltype(arg_mapper<Context>().map(std::declval<T>())),
|
type_constant<decltype(arg_mapper<Context>().map(std::declval<const T&>())),
|
||||||
typename Context::char_type>;
|
typename Context::char_type>;
|
||||||
|
|
||||||
enum { packed_arg_bits = 5 };
|
enum { packed_arg_bits = 5 };
|
||||||
|
@ -649,3 +649,14 @@ TEST(FormatterTest, FormatExplicitlyConvertibleToStringLike) {
|
|||||||
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_like()));
|
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct disabled_rvalue_conversion {
|
||||||
|
operator const char*() const& { return "foo"; }
|
||||||
|
operator const char*()& { return "foo"; }
|
||||||
|
operator const char*() const&& = delete;
|
||||||
|
operator const char*()&& = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(FormatterTest, DisabledRValueConversion) {
|
||||||
|
EXPECT_EQ("foo", fmt::format("{}", disabled_rvalue_conversion()));
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user