]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/type_identity/requirements/typedefs.cc
libstdc++: Remove unnecessary uses of _GLIBCXX_USE_WCHAR_T in testsuite [PR98725]
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / type_identity / requirements / typedefs.cc
CommitLineData
99dee823 1// Copyright (C) 2018-2021 Free Software Foundation, Inc.
ee896276
JW
2//
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)
7// any later version.
8//
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.
13//
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/>.
17
18// { dg-options "-std=gnu++2a" }
19// { dg-do compile { target c++2a } }
20
21#include <type_traits>
22
23template<typename T, typename = typename std::type_identity<T>::type>
24 struct test; // undefined
25
26template<typename T>
27 struct test<T, T> : std::true_type { };
28
29enum test_enum { };
30struct test_class { };
31struct incomplete_class;
32
33void test01()
34{
35 static_assert(test<float>::value, "");
36 static_assert(test<const unsigned int>::value, "");
37 static_assert(test<const unsigned int>::value, "");
38 static_assert(test<volatile unsigned int>::value, "");
39 static_assert(test<const volatile unsigned int>::value, "");
40 static_assert(test<const unsigned char>::value, "");
ee896276 41 static_assert(test<volatile wchar_t>::value, "" );
ee896276
JW
42
43 // Pointers
44 static_assert(test<void*>::value, "");
45 static_assert(test<long*>::value, "");
46 // References
47 static_assert(test<short&>::value, "");
48 static_assert(test<char&&>::value, "");
49 static_assert(test<int*&>::value, "");
50 // Arrays
51 static_assert(test<int[]>::value, "");
52 static_assert(test<int[2]>::value, "");
53 static_assert(test<int[2][3]>::value, "");
54 static_assert(test<int(*)[2]>::value, "");
55 static_assert(test<int(&)[2]>::value, "");
56
57 static_assert(test<test_enum>::value, "");
58 static_assert(test<test_class>::value, "");
59 static_assert(test<incomplete_class>::value, "");
60
61 // Functions
62 static_assert(test<void(*)()>::value, "");
63 static_assert(test<int(*)(int) noexcept>::value, "");
64 static_assert(test<void(&)()>::value, "");
65 static_assert(test<long(&)(long) noexcept>::value, "");
66 static_assert(test<void()>::value, "");
67 static_assert(test<int(int, int)>::value, "");
68 static_assert(test<void() noexcept>::value, "");
69 static_assert(test<int(int, int) noexcept>::value, "");
70
71 // Abominable function types
72 static_assert(test<void(int) const>::value, "");
73 static_assert(test<void(int) const volatile>::value, "");
74
75 // Pointers to members
76 static_assert(test<int incomplete_class::*>::value, "");
77 static_assert(test<void(incomplete_class::*)(int)>::value, "");
78 static_assert(test<void(incomplete_class::*)(int) noexcept>::value, "");
79 static_assert(test<void(incomplete_class::*)() const>::value, "");
80 static_assert(test<void(incomplete_class::*)() &>::value, "");
81 static_assert(test<void(incomplete_class::*)() &&>::value, "");
82 static_assert(test<void(incomplete_class::*)() volatile &&>::value, "");
83
84#ifndef __STRICT_ANSI__
85 // GNU Extensions.
29a9de9b 86#ifdef __SIZEOF_INT128__
ee896276
JW
87 static_assert(test<unsigned __int128>::value, "");
88 static_assert(test<unsigned __int128>::value, "");
89#endif
90#endif
91}