Home | History | Annotate | Download | only in ostream.cons
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // UNSUPPORTED: c++98, c++03
     11 
     12 // <ostream>
     13 
     14 // template <class charT, class traits = char_traits<charT> >
     15 // class basic_ostream;
     16 
     17 // basic_ostream(basic_ostream&& rhs);
     18 
     19 #include <ostream>
     20 #include <cassert>
     21 
     22 
     23 template <class CharT>
     24 struct testbuf
     25     : public std::basic_streambuf<CharT>
     26 {
     27     testbuf() {}
     28 };
     29 
     30 template <class CharT>
     31 struct test_ostream
     32     : public std::basic_ostream<CharT>
     33 {
     34     typedef std::basic_ostream<CharT> base;
     35     test_ostream(testbuf<CharT>* sb) : base(sb) {}
     36 
     37     test_ostream(test_ostream&& s)
     38         : base(std::move(s)) {}
     39 };
     40 
     41 
     42 int main()
     43 {
     44     {
     45         testbuf<char> sb;
     46         test_ostream<char> os1(&sb);
     47         test_ostream<char> os(std::move(os1));
     48         assert(os1.rdbuf() == &sb);
     49         assert(os.rdbuf() == 0);
     50         assert(os.tie() == 0);
     51         assert(os.fill() == ' ');
     52         assert(os.rdstate() == os.goodbit);
     53         assert(os.exceptions() == os.goodbit);
     54         assert(os.flags() == (os.skipws | os.dec));
     55         assert(os.precision() == 6);
     56         assert(os.getloc().name() == "C");
     57     }
     58     {
     59         testbuf<wchar_t> sb;
     60         test_ostream<wchar_t> os1(&sb);
     61         test_ostream<wchar_t> os(std::move(os1));
     62         assert(os1.rdbuf() == &sb);
     63         assert(os.rdbuf() == 0);
     64         assert(os.tie() == 0);
     65         assert(os.fill() == L' ');
     66         assert(os.rdstate() == os.goodbit);
     67         assert(os.exceptions() == os.goodbit);
     68         assert(os.flags() == (os.skipws | os.dec));
     69         assert(os.precision() == 6);
     70         assert(os.getloc().name() == "C");
     71     }
     72 }
     73