• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
11 
12 // <system_error>
13 
14 // template <class T> constexpr bool is_error_condition_enum_v;
15 
16 #include <system_error>
17 #include <type_traits>
18 #include "test_macros.h"
19 
20 template <bool Expected, class T>
21 void
test()22 test()
23 {
24     static_assert((std::is_error_condition_enum<T>::value == Expected), "");
25 #if TEST_STD_VER > 14
26     static_assert((std::is_error_condition_enum_v<T>        == Expected), "");
27 #endif
28 }
29 
30 class A {
31     A();
operator std::error_condition() const32     operator std::error_condition () const { return std::error_condition(); }
33 };
34 
35 // Specialize the template for my class
36 namespace std
37 {
38   template <>
39   struct is_error_condition_enum<A> : public std::true_type {};
40 }
41 
42 
main()43 int main()
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