[NFC][analyzer][docs] Crosslink MallocChecker's ownership attributes (#121939)
[llvm-project.git] / libcxx / test / std / diagnostics / syserr / is_error_code_enum.pass.cpp
blob437d0f0a91177af2258ff0d83ccce6f6c888307e
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
11 // <system_error>
13 // template <> struct is_error_code_enum<> : public false_type {};
15 #include <cstddef>
16 #include <string>
17 #include <system_error>
19 #include "test_macros.h"
21 template <bool Expected, class T>
22 void
23 test()
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
32 class A {
33 A();
34 operator std::error_code () const { return std::error_code(); }
37 // Specialize the template for my class
38 template <>
39 struct std::is_error_code_enum<A> : public std::true_type {};
41 int main(int, char**)
43 test<false, void>();
44 test<false, int>();
45 test<false, std::nullptr_t>();
46 test<false, std::string>();
48 test<true, A>();
50 return 0;