Fix formatting of objects convertible to std::string

This commit is contained in:
Victor Zverovich
2018-02-17 12:57:18 +00:00
parent ce4a65ffea
commit 18ac98700e
2 changed files with 17 additions and 6 deletions
+10
View File
@@ -1213,6 +1213,16 @@ TEST(FormatterTest, FormatStringView) {
EXPECT_EQ("test", format("{0}", string_view("test")));
}
struct ConvertibleToString {
std::string s;
ConvertibleToString() : s("foo") {}
operator const std::string &() const { return s; }
};
TEST(FormatterTest, FormatConvertibleToString) {
EXPECT_EQ("foo", format("{}", ConvertibleToString()));
}
namespace fmt {
template <>
struct formatter<Date> {