Consider the following line:
std::string s = (std::stringstream() << "foo").str();
This should not compile because std::stringstream::operator<<() is inherited by std::ostream and returns a std::ostream& which does not have an str() member.
It seems the main compilers are now accepting this code where they didn't in the past. What standard change happened to make this compile?
I made some tests with GCC, Clang and MSVC and I could find the version where the change happened:
| Compiler | Rejects until (version) | Accepts from (version) |
|---|---|---|
| GCC | 11.1 | 11.2 |
| Clang | 12.0.1 | 13.0.0 |
| MSVC | v19.14 | v19.15 |
You can find the test here