Fix formatting of abstract classes via ostream

This commit is contained in:
Victor Zverovich
2021-09-02 08:19:12 -07:00
parent 8029bf955c
commit ee0659f8b6
2 changed files with 17 additions and 3 deletions
+13
View File
@@ -23,6 +23,7 @@ template <> struct formatter<test> : formatter<int> {
#include <sstream>
#include "fmt/compile.h"
#include "fmt/ostream.h"
#include "fmt/ranges.h"
#include "gmock/gmock.h"
@@ -280,3 +281,15 @@ TEST(ostream_test, range) {
auto strs = std::vector<test_string>{test_string("foo"), test_string("bar")};
EXPECT_EQ("[foo, bar]", fmt::format("{}", strs));
}
struct abstract {
virtual ~abstract() = default;
virtual void f() = 0;
friend std::ostream& operator<<(std::ostream& os, const abstract&) {
return os;
}
};
void format_abstract_compiles(const abstract& a) {
fmt::format(FMT_COMPILE("{}"), a);
}