If there is a support function va_list
std::string StrTest(int x, ...)
{
va_list args;
va_start(args, x);
std::string s = fmt::format("{0} {1} {0}.", args);
va_end(args);
return s;
}
StrTest(1, "one", 2)
Varargs are not supported because they are inherently unsafe, but you can use variadic templates instead:
#include "fmt/format.h"
template <typename... T>
std::string StrTest(int x, const T & ... args) {
return fmt::format("{0} {1} {0}.", args...);
}
StrTest(1, "one", 2);
FMT_VARIADIC and fmt::ArgList for pre-C++11
Most helpful comment
Varargs are not supported because they are inherently unsafe, but you can use variadic templates instead: