On Tue, Jan 3, 2017 at 3:16 PM, Christof Donat
Hin
Am 03.01.2017 14:20, schrieb Olaf van der Spek:
On Tue, Jan 3, 2017 at 2:19 PM, Christof Donat
wrote: Am 01.01.2017 00:21, schrieb Andrey Semashev:
throw std::runtime_error(format(std::string()) << "Error " << 47);
How would that differ from
throw std::runtime_error((std::ostringstream{} << "Error " << 47).str());
Simpler syntax, better performance
I see the chances for better performance, but for the syntax I don't really see any remarkable improvements.
The extra parentheses and the .str() part are annoying.. same goes for boost::format. How about this one? throw std::runtime_error("Error "s << 47);
If performance matters, I'd try with boost::spirit::karma. The syntax will
Performance matters but it's not the only thing that matters. What solution do you think someone new to C++ understands better?
If you have multiple places like that in your code, I guess, you'd like to wrap it into a generic function and you have a similar API to the "append()" proposal. Now I see, how it might be useful, thanks. I think, append() should rely on karma generators then, instead of yet another int to string implementation, because we only already have five dozens.
It's an implementation detail but yes, it might be useful. -- Olaf