§27.7.3.9
defines the following overload for operator<<
:
template
basic_ostream&
It's a defect and it is my fault, sorry. LWG 1203 (thanks for finding that for me! :-)) is my current opinion of the correct fix for the "rvalue-stream-inserter". Note though that you could still catch it and be in trouble:
auto&& s = (std::stringstream() << "hi there!\n");
std::cout << s.rdbuf(); // oops
Though at least in the above code it is a little more obvious (because of the &&
) that you're doing something you shouldn't.