| 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, c++11, c++14 |
| 11 | // UNSUPPORTED: availability-filesystem-missing |
| 12 | |
| 13 | // <filesystem> |
| 14 | |
| 15 | // class path |
| 16 | |
| 17 | // operator string_type() const; |
| 18 | |
| 19 | #include <filesystem> |
| 20 | #include <cassert> |
| 21 | #include <string> |
| 22 | #include <type_traits> |
| 23 | |
| 24 | #include "assert_macros.h" |
| 25 | #include "test_macros.h" |
| 26 | namespace fs = std::filesystem; |
| 27 | |
| 28 | int main(int, char**) { |
| 29 | using namespace fs; |
| 30 | using string_type = path::string_type; |
| 31 | const char* const value = "hello world" ; |
| 32 | std::string value_str(value); |
| 33 | fs::path::string_type pathstr_value(value_str.begin(), value_str.end()); |
| 34 | { // Check signature |
| 35 | path p(value); |
| 36 | static_assert(std::is_convertible<path, string_type>::value, "" ); |
| 37 | static_assert(std::is_constructible<string_type, path>::value, "" ); |
| 38 | ASSERT_SAME_TYPE(string_type, decltype(p.operator string_type())); |
| 39 | ASSERT_NOT_NOEXCEPT(p.operator string_type()); |
| 40 | } |
| 41 | { |
| 42 | path p(value); |
| 43 | assert(p.native() == pathstr_value); |
| 44 | string_type s = p; |
| 45 | assert(s == pathstr_value); |
| 46 | assert(p == pathstr_value); |
| 47 | } |
| 48 | |
| 49 | return 0; |
| 50 | } |
| 51 | |