From 50584f42b427f247f0d1d1103f284d1dbde09817 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 18 Jul 2018 16:24:46 -0700 Subject: [PATCH] Test formatting of an object with templated conversion to string-like --- test/format-test.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/format-test.cc b/test/format-test.cc index 2b3ac5fa..2b720876 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1102,6 +1102,18 @@ struct explicitly_convertible_to_string_view { TEST(FormatterTest, FormatExplicitlyConvertibleToStringView) { EXPECT_EQ("foo", format("{}", explicitly_convertible_to_string_view())); } + +struct explicitly_convertible_to_string_like { + template < + typename String, + typename = typename std::enable_if< + std::is_constructible::value>::type> + explicit operator String() const { return String("foo", 3u); } +}; + +TEST(FormatterTest, FormatExplicitlyConvertibleToStringLike) { + EXPECT_EQ("foo", format("{}", explicitly_convertible_to_string_like())); +} #endif FMT_BEGIN_NAMESPACE