On Tue, Jan 3, 2017 at 3:48 PM, Christof Donat
Hi,
Am 03.01.2017 15:23, schrieb Olaf van der Spek:
On Tue, Jan 3, 2017 at 3:16 PM, Christof Donat
wrote: The extra parentheses and the .str() part are annoying.. same goes for boost::format. I see. For me that is not a big issue, but people are different.
I think the language still doesn't allow temporaries to bind to mutable& so we might've cheered too soon.. :(
How about this one?
throw std::runtime_error("Error "s << 47);
Uh. How does that work with
std::cout << "Error "s << 47;
Will that be
(std::cout << "Error "s) << 47;
or
std::cout << ("Error "s << 47);
We've got rules for that.. http://en.cppreference.com/w/cpp/language/operator_precedence
Also I'd expect a std::string to behave like a stream then and try to use e.g. manipulators. Maybe that would be acceptable with a different operator. e.g. like in SQL:
throw std::runtime_error("Error "s || 47);
Now this is explicit:
std::cout << "Error "s || 47; // versus
Why would you want to combine << for ostream and string? Just use the ostream one in both cases. I think << is quite elegant. -- Olaf