• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // <fstream>
11 
12 // template <class charT, class traits = char_traits<charT> >
13 // class basic_filebuf
14 
15 // basic_filebuf& operator=(basic_filebuf&& rhs);
16 
17 #include <fstream>
18 #include <cassert>
19 
main()20 int main()
21 {
22 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
23     char temp[L_tmpnam];
24     tmpnam(temp);
25     {
26         std::filebuf f;
27         assert(f.open(temp, std::ios_base::out | std::ios_base::in
28                                                | std::ios_base::trunc) != 0);
29         assert(f.is_open());
30         assert(f.sputn("123", 3) == 3);
31         f.pubseekoff(1, std::ios_base::beg);
32         assert(f.sgetc() == '2');
33         std::filebuf f2;
34         f2 = move(f);
35         assert(!f.is_open());
36         assert(f2.is_open());
37         assert(f2.sgetc() == '2');
38     }
39     remove(temp);
40     {
41         std::wfilebuf f;
42         assert(f.open(temp, std::ios_base::out | std::ios_base::in
43                                                | std::ios_base::trunc) != 0);
44         assert(f.is_open());
45         assert(f.sputn(L"123", 3) == 3);
46         f.pubseekoff(1, std::ios_base::beg);
47         assert(f.sgetc() == L'2');
48         std::wfilebuf f2;
49         f2 = move(f);
50         assert(!f.is_open());
51         assert(f2.is_open());
52         assert(f2.sgetc() == L'2');
53     }
54     remove(temp);
55 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
56 }
57