
Am 16.01.2017 09:54, schrieb Olaf van der Spek:
On Sun, Jan 15, 2017 at 9:42 PM, Damien Buhl <damien.buhl@lecbna.org> wrote:
Libraries like boost::format have their strengths, when simply concatenating information does not fit the needs. E.g. for internationalized text output. I like boost::format a lot, but speed actually is not its focus. I personally uses boost::format alot, but I think boost::format would be easier and shorter to use if it would be callable with an `std::string snprintf(format_str, args...)`. And it would be awesome that
On 15/01/2017 14:39, Christof Donat wrote: format_str would be, if already known at compile time handled with Metaparse. Sorry for getting off-topic. :D
Can't boost::format be updated to a variadic variant?
I think so. Something like this should be possible, of course: auto format_args_imp(const boost::format& f) -> const boost::format& { return f; } template<typename Arg1, typename ... Args> auto format_args_imp(const boost::format& f, Arg1 arg1, Args ... args) -> const boost::format& { return format_args_impl(f % arg1, args...); } template<typename ... Args> auto format_args(const std::string& f, Args...args) -> std::string { return format_args_impl(f, args...).str(); } // ... auto first_which = format_args("When shall we %1% meet again? In %2%, %3%, or in %4%?"s, 3, "thunder"s, "lightning"s, "rain"s); I have not tried to compile this, so please just take it as a sketch. It inherits most of the advantages and disadvantages of boost::format, of course. Christof