• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 // UNSUPPORTED: c++03
10 
11 // <filesystem>
12 
13 // class path
14 
15 // path& operator=(path&&) noexcept
16 
17 #include "filesystem_include.h"
18 #include <type_traits>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 #include "count_new.h"
23 
24 
main(int,char **)25 int main(int, char**) {
26   using namespace fs;
27   static_assert(std::is_nothrow_move_assignable<path>::value, "");
28   assert(globalMemCounter.checkOutstandingNewEq(0));
29   const std::string s("we really really really really really really really "
30                       "really really long string so that we allocate");
31   assert(globalMemCounter.checkOutstandingNewEq(1));
32   const fs::path::string_type ps(s.begin(), s.end());
33   path p(s);
34   {
35     DisableAllocationGuard g;
36     path p2;
37     path& pref = (p2 = std::move(p));
38     assert(p2.native() == ps);
39     assert(p.native() != ps); // Testing moved from state
40     assert(&pref == &p2);
41   }
42 
43   return 0;
44 }
45