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 | |
11 | // <filesystem> |
12 | |
13 | // enum class perm_options; |
14 | |
15 | #include <filesystem> |
16 | #include <type_traits> |
17 | #include <cassert> |
18 | |
19 | #include "test_macros.h" |
20 | #include "check_bitmask_types.h" |
21 | namespace fs = std::filesystem; |
22 | |
23 | constexpr fs::perm_options ME(int val) { |
24 | return static_cast<fs::perm_options>(val); |
25 | } |
26 | |
27 | int main(int, char**) { |
28 | typedef fs::perm_options E; |
29 | static_assert(std::is_enum<E>::value, "" ); |
30 | |
31 | // Check that E is a scoped enum by checking for conversions. |
32 | typedef std::underlying_type<E>::type UT; |
33 | static_assert(!std::is_convertible<E, UT>::value, "" ); |
34 | |
35 | LIBCPP_STATIC_ASSERT(std::is_same<UT, unsigned char >::value, "" ); // Implementation detail |
36 | |
37 | typedef check_bitmask_type<E, E::replace, E::nofollow> BitmaskTester; |
38 | assert(BitmaskTester::check()); |
39 | |
40 | static_assert( |
41 | E::replace == ME(val: 1) && |
42 | E::add == ME(val: 2) && |
43 | E::remove == ME(val: 4) && |
44 | E::nofollow == ME(val: 8), |
45 | "Expected enumeration values do not match" ); |
46 | |
47 | return 0; |
48 | } |
49 | |