Re: A better way of formatting strings?
On Mar 24, 3:49 pm, Leigh Johnston <le...@i42.co.uk> wrote:
On 24/03/2011 15:34, Michael Doubez wrote:
[...]
Concerning the form, I'd prefer:
std::string myformattedstring = ("The cat is ",fmt::_1,"cm tall and
the mouse is ",fmt::_2,"cm tall.")
, cat_len, mouse_len;
I'd be interested in seeing how that could be implemented
without varargs, and the resulting loss of type safety.
That does not lend itself to well to localization; consider boost.format
instead.
boost::format solves one small aspect of localization, but in
practice, it's rarely enough. I had a class which did the same
thing, long before there was boost, and I gradually stopped
maintaining it, because it didn't solve any real problems
satisfactorily. (And unlike boost::format, it didn't really
work with manipulators. And you really want user defined
manipulators to define semantic markup.) As soon as more than
one language is involved, you almost always have to have a
separate dll, with specially written code, for each language.
--
James Kanze