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

source code of libcxx/test/std/diagnostics/syserr/is_error_code_enum.pass.cpp