move.pass.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // UNSUPPORTED: c++98, c++03
  10. // <fstream>
  11. // template <class charT, class traits = char_traits<charT> >
  12. // class basic_fstream
  13. // basic_fstream(basic_fstream&& rhs);
  14. #include <fstream>
  15. #include <cassert>
  16. #include "platform_support.h"
  17. int main()
  18. {
  19. std::string temp = get_temp_file_name();
  20. {
  21. std::fstream fso(temp, std::ios_base::in | std::ios_base::out
  22. | std::ios_base::trunc);
  23. std::fstream fs = move(fso);
  24. double x = 0;
  25. fs << 3.25;
  26. fs.seekg(0);
  27. fs >> x;
  28. assert(x == 3.25);
  29. }
  30. std::remove(temp.c_str());
  31. {
  32. std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
  33. | std::ios_base::trunc);
  34. std::wfstream fs = move(fso);
  35. double x = 0;
  36. fs << 3.25;
  37. fs.seekg(0);
  38. fs >> x;
  39. assert(x == 3.25);
  40. }
  41. std::remove(temp.c_str());
  42. }