move.pass.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // <experimental/filesystem>
  11. // class path
  12. // path& operator=(path&&) noexcept
  13. #include "filesystem_include.hpp"
  14. #include <type_traits>
  15. #include <cassert>
  16. #include "test_macros.h"
  17. #include "count_new.hpp"
  18. int main() {
  19. using namespace fs;
  20. static_assert(std::is_nothrow_move_assignable<path>::value, "");
  21. assert(globalMemCounter.checkOutstandingNewEq(0));
  22. const std::string s("we really really really really really really really "
  23. "really really long string so that we allocate");
  24. assert(globalMemCounter.checkOutstandingNewEq(1));
  25. path p(s);
  26. {
  27. DisableAllocationGuard g;
  28. path p2;
  29. path& pref = (p2 = std::move(p));
  30. assert(p2.native() == s);
  31. assert(p.native() != s); // Testing moved from state
  32. assert(&pref == &p2);
  33. }
  34. }