Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 = char_traits<charT> > |
| 13 | // class basic_istream; |
| 14 | |
| 15 | // basic_istream(basic_istream&& rhs); |
| 16 | |
| 17 | #include <istream> |
| 18 | #include <cassert> |
| 19 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 20 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | |
| 22 | template <class CharT> |
| 23 | struct testbuf |
| 24 | : public std::basic_streambuf<CharT> |
| 25 | { |
| 26 | testbuf() {} |
| 27 | }; |
| 28 | |
| 29 | template <class CharT> |
| 30 | struct test_istream |
| 31 | : public std::basic_istream<CharT> |
| 32 | { |
| 33 | typedef std::basic_istream<CharT> base; |
| 34 | test_istream(testbuf<CharT>* sb) : base(sb) {} |
| 35 | |
| 36 | test_istream(test_istream&& s) |
| 37 | : base(std::move(s)) {} |
| 38 | }; |
| 39 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 40 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 41 | |
| 42 | int main() |
| 43 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 44 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | { |
| 46 | testbuf<char> sb; |
| 47 | test_istream<char> is1(&sb); |
| 48 | test_istream<char> is(std::move(is1)); |
| 49 | assert(is1.rdbuf() == &sb); |
| 50 | assert(is1.gcount() == 0); |
| 51 | assert(is.gcount() == 0); |
| 52 | assert(is.rdbuf() == 0); |
| 53 | assert(is.tie() == 0); |
| 54 | assert(is.fill() == ' '); |
| 55 | assert(is.rdstate() == is.goodbit); |
| 56 | assert(is.exceptions() == is.goodbit); |
| 57 | assert(is.flags() == (is.skipws | is.dec)); |
| 58 | assert(is.precision() == 6); |
| 59 | assert(is.getloc().name() == "C"); |
| 60 | } |
| 61 | { |
| 62 | testbuf<wchar_t> sb; |
| 63 | test_istream<wchar_t> is1(&sb); |
| 64 | test_istream<wchar_t> is(std::move(is1)); |
| 65 | assert(is1.gcount() == 0); |
| 66 | assert(is.gcount() == 0); |
| 67 | assert(is1.rdbuf() == &sb); |
| 68 | assert(is.rdbuf() == 0); |
| 69 | assert(is.tie() == 0); |
| 70 | assert(is.fill() == L' '); |
| 71 | assert(is.rdstate() == is.goodbit); |
| 72 | assert(is.exceptions() == is.goodbit); |
| 73 | assert(is.flags() == (is.skipws | is.dec)); |
| 74 | assert(is.precision() == 6); |
| 75 | assert(is.getloc().name() == "C"); |
| 76 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 77 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 78 | } |