summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/input.output/iostream.format
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/input.output/iostream.format')
-rw-r--r--libcxx/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
index 5b7664e3f55..77c41b09ad7 100644
--- a/libcxx/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
@@ -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);
+ }
}
OpenPOWER on IntegriCloud