On 01/03/17 17:23, Olaf van der Spek wrote:
On Tue, Jan 3, 2017 at 3:16 PM, Christof Donat
wrote: 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);
Well, if we're using UDLs, we might as well use my `format` proposal or a stream or Boost.Format behind the scene. throw std::runtime_error("Error "fmt << 47); throw std::runtime_error("Error "strm << 47); throw std::runtime_error("Error %d"fmt % 47); Each of the UDL operators would create a wrapper that implements formatting and is convertible to std::string. No need to infect std::string itself with formatting.