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. // <fstream>
  10. // template <class charT, class traits = char_traits<charT> >
  11. // class basic_fstream
  12. // basic_fstream& operator=(basic_fstream&& rhs);
  13. #include <fstream>
  14. #include <cassert>
  15. int main()
  16. {
  17. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  18. char temp[L_tmpnam];
  19. tmpnam(temp);
  20. {
  21. std::fstream fso(temp, 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);
  32. {
  33. std::wfstream fso(temp, 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);
  44. #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  45. }