brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · f4d5057 Raw
53 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++03, c++11, c++1410 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 22template <bool Expected, class T>23void24test()25{26    static_assert((std::is_error_condition_enum<T>::value == Expected), "");27#if TEST_STD_VER > 1428    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#endif31}32 33class A {34    A();35    operator std::error_condition () const { return std::error_condition(); }36};37 38// Specialize the template for my class39template <>40struct std::is_error_condition_enum<A> : public std::true_type {};41 42int 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