]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-3.cc
2a52b436fce6e1a5383cab3f44b8d8076b91504d
1 // Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do compile { target c++11 } }
20 #include <type_traits>
22 // Test for SFINAE-friendly underlying_type
24 template<typename T
, typename
= typename
std::underlying_type
<T
>::type
>
25 constexpr bool is_enum(int) { return true; }
28 constexpr bool is_enum(...) { return false; }
34 static_assert( is_enum
<E
>(0), "");
36 static_assert( !is_enum
<void>(0), "");
37 static_assert( !is_enum
<int>(0), "");
38 static_assert( !is_enum
<long>(0), "");
39 static_assert( !is_enum
<int*>(0), "");
40 static_assert( !is_enum
<int[]>(0), "");
41 static_assert( !is_enum
<const int*>(0), "");
42 static_assert( !is_enum
<const int&>(0), "");
43 static_assert( !is_enum
<int()>(0), "");
44 static_assert( !is_enum
<int(&)()>(0), "");
45 static_assert( !is_enum
<int(*)()>(0), "");
47 static_assert( !is_enum
<S
>(0), "");
48 static_assert( !is_enum
<S
&>(0), "");
49 static_assert( !is_enum
<S
*>(0), "");
50 static_assert( !is_enum
<int S::*>(0), "");
51 static_assert( !is_enum
<int (S::*)()>(0), "");