diff --git a/include/istream b/include/istream index ee694003a..3a76ba831 100644 --- a/include/istream +++ b/include/istream @@ -1481,9 +1481,9 @@ ws(basic_istream<_CharT, _Traits>& __is) template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& -operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) +operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x) { - __is >> __x; + __is >> _VSTD::forward<_Tp>(__x); return __is; } diff --git a/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp index 5b7664e3f..77c41b09a 100644 --- a/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp +++ b/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp @@ -7,17 +7,18 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template // basic_istream& -// operator>>(basic_istream&& is, T& x); +// operator>>(basic_istream&& is, T&& x); #include +#include #include -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template struct testbuf : public std::basic_streambuf @@ -42,11 +43,13 @@ public: CharT* egptr() const {return base::egptr();} }; -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +struct A{}; +bool called = false; +void operator>>(std::istream&, A&&){ called = true; } int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { testbuf sb(" 123"); int i = 0; @@ -59,5 +62,11 @@ int main() std::wistream(&sb) >> i; assert(i == 123); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + { // test perfect forwarding + assert(called == false); + std::istringstream ss; + auto& out = (std::move(ss) >> A{}); + assert(&out == &ss); + assert(called); + } } diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html index 3af380617..db3eb839a 100644 --- a/www/cxx1z_status.html +++ b/www/cxx1z_status.html @@ -264,7 +264,7 @@ 2309mutex::lock() should not throw device_or_resource_busyOuluComplete 2310Public exposition only member in std::arrayOuluComplete 2312tuple's constructor constraints need to be phrased more preciselyOuluComplete - 2328Rvalue stream extraction should use perfect forwardingOulu + 2328Rvalue stream extraction should use perfect forwardingOuluComplete 2393std::function's Callable definition is brokenOulu 2422std::numeric_limits<T>::is_modulo description: "most machines" errataOuluComplete 2426Issue about compare_exchangeOulu