[format] convenient format wrapper
I found this boost::format wrapper to be very convenient as replacement of
sprintf. Can something like that be a part of the library?
#include
On 7/09/2013 08:11, Quoth Alexey Klimkin:
I found this boost::format wrapper to be very convenient as replacement of sprintf. Can something like that be a part of the library? [...] template
format& my_format(format& fmter, T value, Args... args) { fmter % value; return my_format(fmter, args...); }
While that's definitely convenient (if you have C++11 variadic templates, anyway), I suspect that sort of construct would create quite a bit of code bloat. (Permutational expansion depending on number and type of parameters.) The compiler *might* be smart enough to save you from most of it via inlining, but I'm not sure how far I'd trust that.
On 09-09-2013 01:16, Gavin Lambert wrote:
On 7/09/2013 08:11, Quoth Alexey Klimkin:
I found this boost::format wrapper to be very convenient as replacement of sprintf. Can something like that be a part of the library? [...] template
format& my_format(format& fmter, T value, Args... args) { fmter % value; return my_format(fmter, args...); } While that's definitely convenient (if you have C++11 variadic templates, anyway), I suspect that sort of construct would create quite a bit of code bloat. (Permutational expansion depending on number and type of parameters.)
The compiler *might* be smart enough to save you from most of it via inlining, but I'm not sure how far I'd trust that.
It seems like what is now being proposed for standardization. If there is code-bloat, then just report this in the documentation. -Thorsten
participants (3)
-
Alexey Klimkin
-
Gavin Lambert
-
Thorsten Ottosen