52 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// UNSUPPORTED: c++0310 11// <system_error>12 13// template <> struct is_error_code_enum<> : public false_type {};14 15#include <cstddef>16#include <string>17#include <system_error>18 19#include "test_macros.h"20 21template <bool Expected, class T>22void23test()24{25 static_assert((std::is_error_code_enum<T>::value == Expected), "");26#if TEST_STD_VER > 1427 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#endif30}31 32class A {33 A();34 operator std::error_code () const { return std::error_code(); }35};36 37// Specialize the template for my class38template <>39struct std::is_error_code_enum<A> : public std::true_type {};40 41int main(int, char**)42{43 test<false, void>();44 test<false, int>();45 test<false, std::nullptr_t>();46 test<false, std::string>();47 48 test<true, A>();49 50 return 0;51}52