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 |
10 | |
11 | // <system_error> |
12 | |
13 | // template <> struct is_error_code_enum<> : public false_type {}; |
14 | |
15 | #include <cstddef> |
16 | #include <string> |
17 | #include <system_error> |
18 | |
19 | #include "test_macros.h" |
20 | |
21 | template <bool Expected, class T> |
22 | void |
23 | test() |
24 | { |
25 | static_assert((std::is_error_code_enum<T>::value == Expected), ""); |
26 | #if TEST_STD_VER > 14 |
27 | static_assert((std::is_error_code_enum_v<T> == Expected), ""); |
28 | ASSERT_SAME_TYPE(decltype(std::is_error_code_enum_v<T>), const bool); |
29 | #endif |
30 | } |
31 | |
32 | class A { |
33 | A(); |
34 | operator std::error_code () const { return std::error_code(); } |
35 | }; |
36 | |
37 | // Specialize the template for my class |
38 | template <> |
39 | struct std::is_error_code_enum<A> : public std::true_type {}; |
40 | |
41 | int main(int, char**) |
42 | { |
43 | test<false, void>(); |
44 | test<false, int>(); |
45 | test<false, std::nullptr_t>(); |
46 | test<false, std::string>(); |
47 | |
48 | test<true, A>(); |
49 | |
50 | return 0; |
51 | } |
52 |