Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<xstring>: Remove spurious operator>>(basic_istream&&, basic_string&) #2052

Closed
StephanTLavavej opened this issue Jul 9, 2021 · 0 comments · Fixed by #2138
Closed

<xstring>: Remove spurious operator>>(basic_istream&&, basic_string&) #2052

StephanTLavavej opened this issue Jul 9, 2021 · 0 comments · Fixed by #2138
Assignees
Labels
enhancement Something can be improved fixed Something works now, yay!

Comments

@StephanTLavavej
Copy link
Member

Noticed by @cpplearner in #2025 (comment).

⚠️ We should wait until #2025 is merged before dealing with this.

The issue is that <xstring> defines an operator>>(basic_istream&&, basic_string&) which doesn't appear in the Standard:

STL/stl/inc/xstring

Lines 4989 to 4991 in e745bad

template <class _Elem, class _Traits, class _Alloc>
basic_istream<_Elem, _Traits>& operator>>(
basic_istream<_Elem, _Traits>&& _Istr, basic_string<_Elem, _Traits, _Alloc>& _Str) {

We should (1) remove this overload and (2) move its guts to operator>>(basic_istream&, basic_string&) which appears in the Standard at WG21-N4892 21.3.4.4 [string.io]/1:

STL/stl/inc/xstring

Lines 5038 to 5042 in e745bad

template <class _Elem, class _Traits, class _Alloc>
basic_istream<_Elem, _Traits>& operator>>(
basic_istream<_Elem, _Traits>& _Istr, basic_string<_Elem, _Traits, _Alloc>& _Str) {
return _STD move(_Istr) >> _Str;
}

Rvalue stream extraction should continue to work (i.e. with no test changes necessary) due to our implementation of 29.7.4.6 [istream.rvalue] operator>>(Istream&&, T&&):

STL/stl/inc/istream

Lines 886 to 891 in e745bad

template <class _Istr, class _Ty,
enable_if_t<conjunction_v<is_convertible<_Istr*, ios_base*>, _Can_stream_in<_Istr, _Ty>>, int> = 0>
_Istr&& operator>>(_Istr&& _Is, _Ty&& _Val) { // extract from rvalue stream
_Is >> _STD forward<_Ty>(_Val);
return _STD move(_Is);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant