2498. operator>>(basic_istream&&, T&&) returns basic_istream&, but should probably return basic_istream&&

Section: 30.7.4.5 [istream.rvalue] Status: New Submitter: Richard Smith Opened: 2015-05-08 Last modified: 2017-02-02

Priority: 3

View all other issues in [istream.rvalue].

View all issues with New status.

Discussion:

Consider:

auto& is = make_istream() >> x; // oops, istream object is already gone

With a basic_istream&& return type, the above would be ill-formed, and generally we'd preserve the value category properly.

[2015-06, Telecon]

JW: think this needs proper consideration, it would make

stream() >> x >> y >> z
go from 3 operator>> calls to 6 operator>> calls, and wouldn't prevent dangling references (change the example to auto&&)

Proposed resolution: