move.pass.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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(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_constructible<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(std::move(p));
  29. assert(p2.native() == s);
  30. assert(p.native() != s); // Testing moved from state
  31. }
  32. }