1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03
13 // template <class charT, class traits, class T>
14 // basic_istream<charT, traits>&
15 // operator>>(basic_istream<charT, traits>&& is, T&& x);
21 #include "test_macros.h"
23 template <class CharT
>
25 : public std::basic_streambuf
<CharT
>
27 typedef std::basic_string
<CharT
> string_type
;
28 typedef std::basic_streambuf
<CharT
> base
;
34 testbuf(const string_type
& 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();}
50 void operator>>(std::istream
&, A
&&){ called
= true; }
55 testbuf
<char> sb(" 123");
57 std::istream(&sb
) >> i
;
61 testbuf
<wchar_t> sb(L
" 123");
63 std::wistream(&sb
) >> i
;
66 { // test perfect forwarding
67 assert(called
== false);
68 std::istringstream ss
;
69 auto&& out
= (std::move(ss
) >> A
{});