Don't use const char* overload of operator<< (#1309)

This commit is contained in:
Victor Zverovich
2019-09-23 12:35:08 -07:00
parent 758446c80d
commit f29901097f
2 changed files with 17 additions and 5 deletions
+12
View File
@@ -242,3 +242,15 @@ TEST(FormatTest, UDL) {
EXPECT_EQ("{}"_format("test"), "test");
}
#endif
template <typename T>
struct convertible {
T value;
explicit convertible(const T& val) : value(val) {}
operator T() const { return value; }
};
TEST(OStreamTest, ConvertibleToCString) {
EXPECT_EQ("x", fmt::format("{}", convertible<char>('x')));
EXPECT_EQ("foo", fmt::format("{}", convertible<const char*>("foo")));
}