1 
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++03
11 
12 // <filesystem>
13 
14 // class path
15 
16 // operator string_type() const;
17 
18 #include "filesystem_include.h"
19 #include <type_traits>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 #include "filesystem_test_helper.h"
24 
25 
main(int,char **)26 int main(int, char**)
27 {
28   using namespace fs;
29   using string_type = path::string_type;
30   const char* const value = "hello world";
31   std::string value_str(value);
32   fs::path::string_type pathstr_value(value_str.begin(), value_str.end());
33   { // Check signature
34     path p(value);
35     static_assert(std::is_convertible<path, string_type>::value, "");
36     static_assert(std::is_constructible<string_type, path>::value, "");
37     ASSERT_SAME_TYPE(string_type, decltype(p.operator string_type()));
38     ASSERT_NOT_NOEXCEPT(p.operator string_type());
39   }
40   {
41     path p(value);
42     assert(p.native() == pathstr_value);
43     string_type s = p;
44     assert(s == pathstr_value);
45     assert(p == pathstr_value);
46   }
47 
48   return 0;
49 }
50