1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03
12 // <experimental/filesystem>
14 // template <class Tp> struct __is_pathable
17 // In addition to the requirements (5), function template parameters named
18 // `Source` shall be one of:
19 // * basic_string<_ECharT, _Traits, _Alloc>
20 // * InputIterator with a value_type of _ECharT
21 // * A character array, which points to a NTCTS after array-to-pointer decay.
24 #include <experimental/filesystem>
25 #include <type_traits>
28 #include "test_macros.h"
29 #include "test_iterators.h"
30 #include "min_allocator.h"
31 #include "constexpr_char_traits.hpp"
33 namespace fs = std::experimental::filesystem;
35 using fs::__is_pathable;
38 struct Identity { typedef Tp type; };
40 template <class Source>
41 Identity<Source> CheckSourceType(Source const&);
44 using GetSourceType = typename decltype(CheckSourceType(std::declval<Tp>()))::type;
46 template <class Tp, class Exp,
47 class ExpQual = typename std::remove_const<Exp>::type>
48 using CheckPass = std::is_same<ExpQual, GetSourceType<Tp>>;
50 template <class Source>
51 using CheckPassSource = std::integral_constant<bool,
52 CheckPass<Source&, Source>::value &&
53 CheckPass<Source const&, Source>::value &&
54 CheckPass<Source&&, Source>::value &&
55 CheckPass<Source const&&, Source>::value
58 template <class CharT>
60 using value_type = CharT;
61 using string_type = std::basic_string<CharT>;
62 using string_type2 = std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>;
63 using string_view_type = std::basic_string_view<CharT>;
64 using string_view_type2 = std::basic_string_view<CharT, constexpr_char_traits<CharT>>;
65 using cstr_type = CharT* const;
66 using const_cstr_type = const CharT*;
67 using array_type = CharT[25];
68 using const_array_type = const CharT[25];
69 using iter_type = input_iterator<CharT*>;
70 using bad_iter_type = input_iterator<signed char*>;
72 template <class TestT>
73 static void AssertPathable() {
74 static_assert(__is_pathable<TestT>::value, "");
75 static_assert(CheckPassSource<TestT>::value, "cannot pass as Source const&");
76 ASSERT_SAME_TYPE(CharT, typename __is_pathable<TestT>::__char_type);
79 template <class TestT>
80 static void AssertNotPathable() {
81 static_assert(!__is_pathable<TestT>::value, "");
85 AssertPathable<string_type>();
86 AssertPathable<string_type2>();
87 AssertPathable<string_view_type>();
88 AssertPathable<string_view_type2>();
89 AssertPathable<cstr_type>();
90 AssertPathable<const_cstr_type>();
91 AssertPathable<array_type>();
92 AssertPathable<const_array_type>();
93 AssertPathable<iter_type>();
95 AssertNotPathable<CharT>();
96 AssertNotPathable<bad_iter_type>();
97 AssertNotPathable<signed char*>();
102 MakeTestType<char>::Test();
103 MakeTestType<wchar_t>::Test();
104 MakeTestType<char16_t>::Test();
105 MakeTestType<char32_t>::Test();