xref: /llvm-project/libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/copy.pass.cpp (revision ac8c9f1e39e1a773fd81ce23dbf1c80ea186f226)
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, c++11, c++14
10 // UNSUPPORTED: availability-filesystem-missing
11 
12 // <filesystem>
13 
14 // class path
15 
16 // path& operator=(path const&);
17 
18 #include <filesystem>
19 #include <cassert>
20 #include <string>
21 #include <type_traits>
22 
23 #include "test_macros.h"
24 namespace fs = std::filesystem;
25 
main(int,char **)26 int main(int, char**) {
27   using namespace fs;
28   static_assert(std::is_copy_assignable<path>::value, "");
29   static_assert(!std::is_nothrow_copy_assignable<path>::value, "should not be noexcept");
30   const std::string s("foo");
31   const path p(s);
32   path p2;
33   path& pref = (p2 = p);
34   assert(p.string() == s);
35   assert(p2.string() == s);
36   assert(&pref == &p2);
37 
38   return 0;
39 }
40