rvalue.pass.cpp revision 256813f4e7915d64776a4edd5f4765d893b9f062
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <istream> 11 12// template <class charT, class traits, class T> 13// basic_istream<charT, traits>& 14// operator>>(basic_istream<charT, traits>&& is, T& x); 15 16#include <istream> 17#include <cassert> 18 19#ifdef _LIBCPP_MOVE 20 21template <class CharT> 22struct testbuf 23 : public std::basic_streambuf<CharT> 24{ 25 typedef std::basic_string<CharT> string_type; 26 typedef std::basic_streambuf<CharT> base; 27private: 28 string_type str_; 29public: 30 31 testbuf() {} 32 testbuf(const string_type& str) 33 : str_(str) 34 { 35 base::setg(const_cast<CharT*>(str_.data()), 36 const_cast<CharT*>(str_.data()), 37 const_cast<CharT*>(str_.data()) + str_.size()); 38 } 39 40 CharT* eback() const {return base::eback();} 41 CharT* gptr() const {return base::gptr();} 42 CharT* egptr() const {return base::egptr();} 43}; 44 45#endif // _LIBCPP_MOVE 46 47int main() 48{ 49#ifdef _LIBCPP_MOVE 50 { 51 testbuf<char> sb(" 123"); 52 int i = 0; 53 std::istream(&sb) >> i; 54 assert(i == 123); 55 } 56 { 57 testbuf<wchar_t> sb(L" 123"); 58 int i = 0; 59 std::wistream(&sb) >> i; 60 assert(i == 123); 61 } 62#endif // _LIBCPP_MOVE 63} 64