[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / input.output / iostream.format / input.streams / istream.rvalue / rvalue.pass.cpp
blobfe4ad9fa741e896411e03aa0a219250016059d7c
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03
11 // <istream>
13 // template <class charT, class traits, class T>
14 // basic_istream<charT, traits>&
15 // operator>>(basic_istream<charT, traits>&& is, T&& x);
17 #include <istream>
18 #include <sstream>
19 #include <cassert>
21 #include "test_macros.h"
23 template <class CharT>
24 struct testbuf
25 : public std::basic_streambuf<CharT>
27 typedef std::basic_string<CharT> string_type;
28 typedef std::basic_streambuf<CharT> base;
29 private:
30 string_type str_;
31 public:
33 testbuf() {}
34 testbuf(const string_type& str)
35 : str_(str)
37 base::setg(const_cast<CharT*>(str_.data()),
38 const_cast<CharT*>(str_.data()),
39 const_cast<CharT*>(str_.data()) + str_.size());
42 CharT* eback() const {return base::eback();}
43 CharT* gptr() const {return base::gptr();}
44 CharT* egptr() const {return base::egptr();}
48 struct A{};
49 bool called = false;
50 void operator>>(std::istream&, A&&){ called = true; }
52 int main(int, char**)
55 testbuf<char> sb(" 123");
56 int i = 0;
57 std::istream(&sb) >> i;
58 assert(i == 123);
61 testbuf<wchar_t> sb(L" 123");
62 int i = 0;
63 std::wistream(&sb) >> i;
64 assert(i == 123);
66 { // test perfect forwarding
67 assert(called == false);
68 std::istringstream ss;
69 auto&& out = (std::move(ss) >> A{});
70 assert(&out == &ss);
71 assert(called);
74 return 0;