1e69a08baSMarshall Clow //===----------------------------------------------------------------------===//
2e69a08baSMarshall Clow //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e69a08baSMarshall Clow //
7e69a08baSMarshall Clow //===----------------------------------------------------------------------===//
8e69a08baSMarshall Clow //
9e69a08baSMarshall Clow // UNSUPPORTED: c++03
10e69a08baSMarshall Clow 
11450370f3SMarshall Clow // <system_error>
12e69a08baSMarshall Clow 
13e69a08baSMarshall Clow // template <> struct is_error_code_enum<> : public false_type {};
14e69a08baSMarshall Clow 
15450370f3SMarshall Clow #include <system_error>
16e69a08baSMarshall Clow #include <string>
17e69a08baSMarshall Clow #include "test_macros.h"
18e69a08baSMarshall Clow 
19e69a08baSMarshall Clow template <bool Expected, class T>
20e69a08baSMarshall Clow void
test()21e69a08baSMarshall Clow test()
22e69a08baSMarshall Clow {
23e69a08baSMarshall Clow     static_assert((std::is_error_code_enum<T>::value == Expected), "");
24e69a08baSMarshall Clow #if TEST_STD_VER > 14
25e69a08baSMarshall Clow     static_assert((std::is_error_code_enum_v<T>      == Expected), "");
26*93df7b9fSJoe Loser     ASSERT_SAME_TYPE(decltype(std::is_error_code_enum_v<T>), const bool);
27e69a08baSMarshall Clow #endif
28e69a08baSMarshall Clow }
29e69a08baSMarshall Clow 
30e69a08baSMarshall Clow class A {
31e69a08baSMarshall Clow     A();
operator std::error_code() const32e69a08baSMarshall Clow     operator std::error_code () const { return std::error_code(); }
33e69a08baSMarshall Clow };
34e69a08baSMarshall Clow 
35e69a08baSMarshall Clow // Specialize the template for my class
36e69a08baSMarshall Clow namespace std
37e69a08baSMarshall Clow {
38e69a08baSMarshall Clow   template <>
39e69a08baSMarshall Clow   struct is_error_code_enum<A> : public std::true_type {};
40e69a08baSMarshall Clow }
41e69a08baSMarshall Clow 
42e69a08baSMarshall Clow 
main(int,char **)432df59c50SJF Bastien int main(int, char**)
44e69a08baSMarshall Clow {
45e69a08baSMarshall Clow     test<false, void>();
46e69a08baSMarshall Clow     test<false, int>();
47e69a08baSMarshall Clow     test<false, std::nullptr_t>();
48e69a08baSMarshall Clow     test<false, std::string>();
49e69a08baSMarshall Clow 
50e69a08baSMarshall Clow     test<true, A>();
512df59c50SJF Bastien 
522df59c50SJF Bastien   return 0;
53e69a08baSMarshall Clow }
54