Section: 31.7.6.6 [ostream.rvalue], 31.7.5.6 [istream.rvalue] Status: C++17 Submitter: Robert Haberlach Opened: 2015-09-08 Last modified: 2017-07-30
Priority: 3
View all other issues in [ostream.rvalue].
View all issues with C++17 status.
Discussion:
The rvalue stream insertion and extraction operators should be constrained to not participate in overload resolution unless the expression they evaluate is well-formed. Programming code that tests the validity of stream insertions (or extractions) using SFINAE can result in false positives, as the present declarations accept virtually any right-hand side argument. Moreover, there is no need for pollution of the candidate set with ill-formed specializations.
[2016-08 - Chicago]
Thurs AM: Moved to Tentatively Ready
Proposed resolution:
This wording is relative to N4527.
Modify 31.7.6.6 [ostream.rvalue] as indicated:
template <class charT, class traits, class T> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&& os, const T& x);-1- Effects:
-2- Returns:os << x
os
-?- Remarks: This function shall not participate in overload resolution unless the expressionos << x
is well-formed.
Modify 31.7.5.6 [istream.rvalue] as indicated:
template <class charT, class traits, class T> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&& is, T& x);-1- Effects:
-2- Returns:is >> x
is
-?- Remarks: This function shall not participate in overload resolution unless the expressionis >> x
is well-formed.