Author: ericwf Date: Sat Jul 23 23:07:22 2016 New Revision: 276545 URL: http://llvm.org/viewvc/llvm-project?rev=276545&view=rev Log: Implement LWG2328. Rvalue stream extraction should perfect forward.
Modified: libcxx/trunk/include/istream libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/include/istream URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=276545&r1=276544&r2=276545&view=diff ============================================================================== --- libcxx/trunk/include/istream (original) +++ libcxx/trunk/include/istream Sat Jul 23 23:07:22 2016 @@ -1481,9 +1481,9 @@ ws(basic_istream<_CharT, _Traits>& __is) template <class _CharT, class _Traits, class _Tp> 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; } Modified: libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp?rev=276545&r1=276544&r2=276545&view=diff ============================================================================== --- libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp (original) +++ libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp Sat Jul 23 23:07:22 2016 @@ -7,17 +7,18 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <istream> // template <class charT, class traits, class T> // basic_istream<charT, traits>& -// operator>>(basic_istream<charT, traits>&& is, T& x); +// operator>>(basic_istream<charT, traits>&& is, T&& x); #include <istream> +#include <sstream> #include <cassert> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template <class CharT> struct testbuf : public std::basic_streambuf<CharT> @@ -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<char> 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); + } } Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=276545&r1=276544&r2=276545&view=diff ============================================================================== --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Sat Jul 23 23:07:22 2016 @@ -264,7 +264,7 @@ <tr><td><a href="http://wg21.link/LWG2309">2309</a></td><td>mutex::lock() should not throw device_or_resource_busy</td><td>Oulu</td><td>Complete</td></tr> <tr><td><a href="http://wg21.link/LWG2310">2310</a></td><td>Public exposition only member in std::array</td><td>Oulu</td><td>Complete</td></tr> <tr><td><a href="http://wg21.link/LWG2312">2312</a></td><td>tuple's constructor constraints need to be phrased more precisely</td><td>Oulu</td><td>Complete</td></tr> - <tr><td><a href="http://wg21.link/LWG2328">2328</a></td><td>Rvalue stream extraction should use perfect forwarding</td><td>Oulu</td><td></td></tr> + <tr><td><a href="http://wg21.link/LWG2328">2328</a></td><td>Rvalue stream extraction should use perfect forwarding</td><td>Oulu</td><td>Complete</td></tr> <tr><td><a href="http://wg21.link/LWG2393">2393</a></td><td>std::function's Callable definition is broken</td><td>Oulu</td><td></td></tr> <tr><td><a href="http://wg21.link/LWG2422">2422</a></td><td>std::numeric_limits<T>::is_modulo description: "most machines" errata</td><td>Oulu</td><td>Complete</td></tr> <tr><td><a href="http://wg21.link/LWG2426">2426</a></td><td>Issue about compare_exchange</td><td>Oulu</td><td></td></tr> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits