move.pass.cpp 1.1 KB

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