Skip to content

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

Description

Noticed by S. B. Tam (@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);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementSomething can be improvedfixedSomething works now, yay!

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions