mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-05 16:49:48 +01:00
FMT_VARIADIC_CONST - Support for const variadic methods (#591)
FMT_VARIADIC_CONST - Support for const variadic methods
This commit is contained in:
committed by
Victor Zverovich
parent
324415c036
commit
7a9c1ba190
@@ -1630,6 +1630,24 @@ TEST(FormatTest, FormatMessageExample) {
|
||||
format_message(42, "{} happened", "something"));
|
||||
}
|
||||
|
||||
class test_class
|
||||
{
|
||||
public:
|
||||
std::string format_message(int id, const char *format,const fmt::ArgList &args) const {
|
||||
MemoryWriter w;
|
||||
w.write("[{}] ", id);
|
||||
w.write(format, args);
|
||||
return w.str();
|
||||
}
|
||||
FMT_VARIADIC_CONST(std::string, format_message, int, const char *)
|
||||
};
|
||||
|
||||
TEST(FormatTest, ConstFormatMessage) {
|
||||
test_class c;
|
||||
EXPECT_EQ("[42] something happened",
|
||||
c.format_message(42, "{} happened", "something"));
|
||||
}
|
||||
|
||||
#if FMT_USE_VARIADIC_TEMPLATES
|
||||
template<typename... Args>
|
||||
void print_error(const char *file, int line, const char *format,
|
||||
|
||||
Reference in New Issue
Block a user