move.pass.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // UNSUPPORTED: c++98, c++03
  9. // <filesystem>
  10. // class path
  11. // path(path&&) noexcept
  12. #include "filesystem_include.hpp"
  13. #include <type_traits>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. #include "count_new.hpp"
  17. int main(int, char**) {
  18. using namespace fs;
  19. static_assert(std::is_nothrow_move_constructible<path>::value, "");
  20. assert(globalMemCounter.checkOutstandingNewEq(0));
  21. const std::string s("we really really really really really really really "
  22. "really really long string so that we allocate");
  23. assert(globalMemCounter.checkOutstandingNewEq(1));
  24. path p(s);
  25. {
  26. DisableAllocationGuard g;
  27. path p2(std::move(p));
  28. assert(p2.native() == s);
  29. assert(p.native() != s); // Testing moved from state
  30. }
  31. return 0;
  32. }