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++03 11 12 // <system_error> 13 14 // template <> struct is_error_code_enum<> : public false_type {}; 15 16 #include <system_error> 17 #include <string> 18 #include "test_macros.h" 19 20 template <bool Expected, class T> 21 void test()22test() 23 { 24 static_assert((std::is_error_code_enum<T>::value == Expected), ""); 25 #if TEST_STD_VER > 14 26 static_assert((std::is_error_code_enum_v<T> == Expected), ""); 27 #endif 28 } 29 30 class A { 31 A(); operator std::error_code() const32 operator std::error_code () const { return std::error_code(); } 33 }; 34 35 // Specialize the template for my class 36 namespace std 37 { 38 template <> 39 struct is_error_code_enum<A> : public std::true_type {}; 40 } 41 42 main()43int 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