The stream operator << dosen't work as expected, based on the use being equivalent to std::ostream.
fmt::Formatter<> msg = fmt::Format(format);
msg << arg1;
msg << arg2;
...
msg << argN;
result = fmt::str(msg);
throws exception, to many formatting tokens on the second line, as it immediately attempts to format the string, but not all arguments have been passed.
P.S. I need to use this method as my code is actually
template<typename... Args> inline std::string const & Format(std::string const &format,Args const & ... args) {
fmt::Formatter<> msg = fmt::Format(format);
RescursiveFormat(msg,args...);
return *new std::string(fmt::str(msg)); }
Where RescursiveFormat(msg,args...); reduce to (by template meta programing, and compiler optimization)
msg << arg1;
msg << arg2;
...
msg << argN;
For however may arguments are passed.
This allows formatting to be done by
Format(<format_string>,...) i.e. like sprintf, by type-safe, and using format as the underlining formatting method.
The stream operator << dosen't work as expected, based on the use being equivalent to std::ostream.
throws exception, to many formatting tokens on the second line, as it immediately attempts to format the string, but not all arguments have been passed.
P.S. I need to use this method as my code is actually
Where RescursiveFormat(msg,args...); reduce to (by template meta programing, and compiler optimization)
For however may arguments are passed.
This allows formatting to be done by
Format(<format_string>,...) i.e. like sprintf, by type-safe, and using format as the underlining formatting method.