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, c++11, c++14 10 11 // <system_error> 12 13 // template <class T> constexpr bool is_error_condition_enum_v; 14 15 #include <string> 16 #include <system_error> 17 #include <type_traits> 18 #include "test_macros.h" 19 20 template <bool Expected, class T> 21 void 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 ASSERT_SAME_TYPE(decltype(std::is_error_condition_enum_v<T>), const bool); 28 #endif 29 } 30 31 class A { 32 A(); 33 operator std::error_condition () const { return std::error_condition(); } 34 }; 35 36 // Specialize the template for my class 37 namespace std 38 { 39 template <> 40 struct is_error_condition_enum<A> : public std::true_type {}; 41 } 42 43 44 int main(int, char**) 45 { 46 test<false, void>(); 47 test<false, int>(); 48 test<false, std::nullptr_t>(); 49 test<false, std::string>(); 50 51 test<true, A>(); 52 53 return 0; 54 } 55