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 <cstddef> 16 #include <string> 17 #include <system_error> 18 #include <type_traits> 19 20 #include "test_macros.h" 21 22 template <bool Expected, class T> 23 void 24 test() 25 { 26 static_assert((std::is_error_condition_enum<T>::value == Expected), ""); 27 #if TEST_STD_VER > 14 28 static_assert((std::is_error_condition_enum_v<T> == Expected), ""); 29 ASSERT_SAME_TYPE(decltype(std::is_error_condition_enum_v<T>), const bool); 30 #endif 31 } 32 33 class A { 34 A(); 35 operator std::error_condition () const { return std::error_condition(); } 36 }; 37 38 // Specialize the template for my class 39 template <> 40 struct std::is_error_condition_enum<A> : public std::true_type {}; 41 42 int main(int, char**) 43 { 44 test<false, void>(); 45 test<false, int>(); 46 test<false, std::nullptr_t>(); 47 test<false, std::string>(); 48 49 test<true, A>(); 50 51 return 0; 52 } 53