move_assign.pass.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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& operator=(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.c_str(), std::ios_base::in | std::ios_base::out
  22. | std::ios_base::trunc);
  23. std::fstream fs;
  24. fs = move(fso);
  25. double x = 0;
  26. fs << 3.25;
  27. fs.seekg(0);
  28. fs >> x;
  29. assert(x == 3.25);
  30. }
  31. std::remove(temp.c_str());
  32. {
  33. std::wfstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
  34. | std::ios_base::trunc);
  35. std::wfstream fs;
  36. fs = move(fso);
  37. double x = 0;
  38. fs << 3.25;
  39. fs.seekg(0);
  40. fs >> x;
  41. assert(x == 3.25);
  42. }
  43. std::remove(temp.c_str());
  44. }