Fix type safety when using custom formatters (#394)

This commit is contained in:
Victor Zverovich
2016-10-07 08:37:06 -07:00
parent 506435bf71
commit dafbec7553
6 changed files with 143 additions and 116 deletions
+6 -3
View File
@@ -1633,16 +1633,19 @@ class MockArgFormatter :
MOCK_METHOD1(visit_int, void (int value));
};
void vcustom_format(const char *format_str, fmt::format_args args) {
typedef fmt::BasicFormatter<char, MockArgFormatter> CustomFormatter;
void custom_vformat(const char *format_str,
fmt::basic_format_args<CustomFormatter> args) {
fmt::MemoryWriter writer;
fmt::BasicFormatter<char, MockArgFormatter> formatter(args, writer);
CustomFormatter formatter(args, writer);
formatter.format(format_str);
}
template <typename... Args>
void custom_format(const char *format_str, const Args & ... args) {
auto va = fmt::make_format_args<fmt::BasicFormatter<char>>(args...);
return vcustom_format(format_str, va);
return custom_vformat(format_str, va);
}
TEST(FormatTest, CustomArgFormatter) {