]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do compile { target c++11 } } |
ae29d025 | 2 | |
7adcbafe | 3 | // Copyright (C) 2013-2022 Free Software Foundation, Inc. |
ae29d025 PC |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 3, or (at your option) | |
9 | // any later version. | |
10 | // | |
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING3. If not see | |
18 | // <http://www.gnu.org/licenses/>. | |
19 | ||
20 | #include <type_traits> | |
21 | #include <testsuite_tr1.h> | |
22 | ||
23 | class HiddenCons | |
24 | { | |
25 | HiddenCons(); | |
26 | HiddenCons(const HiddenCons&); | |
27 | }; | |
28 | ||
29 | class DerivedHiddenCons | |
30 | : private HiddenCons | |
31 | { | |
32 | DerivedHiddenCons(); | |
33 | DerivedHiddenCons(const DerivedHiddenCons&); | |
34 | }; | |
35 | ||
36 | class MultiDerivedHiddenCons | |
37 | : private HiddenCons, private __gnu_test::ClassType | |
38 | { | |
39 | MultiDerivedHiddenCons(); | |
40 | MultiDerivedHiddenCons(const MultiDerivedHiddenCons&); | |
41 | }; | |
42 | ||
43 | void test01() | |
44 | { | |
45 | using std::is_base_of; | |
46 | using namespace __gnu_test; | |
47 | ||
48 | // Positive tests. | |
a0d026d9 PC |
49 | static_assert(test_relationship<is_base_of, volatile ClassType, |
50 | ClassType>(true), ""); | |
ae29d025 PC |
51 | static_assert(test_relationship<is_base_of, AbstractClass, |
52 | AbstractClass>(true), ""); | |
53 | static_assert(test_relationship<is_base_of, ClassType, | |
54 | DerivedType>(true), ""); | |
55 | static_assert(test_relationship<is_base_of, ClassType, | |
56 | const DerivedType>(true), ""); | |
57 | static_assert(test_relationship<is_base_of, volatile ClassType, | |
58 | volatile DerivedType>(true), ""); | |
59 | static_assert(test_relationship<is_base_of, PolymorphicClass, | |
60 | DerivedPolymorphic>(true), ""); | |
61 | static_assert(test_relationship<is_base_of, HiddenCons, | |
62 | DerivedHiddenCons>(true), ""); | |
63 | static_assert(test_relationship<is_base_of, HiddenCons, | |
64 | MultiDerivedHiddenCons>(true), ""); | |
65 | static_assert(test_relationship<is_base_of, ClassType, | |
66 | MultiDerivedHiddenCons>(true), ""); | |
67 | ||
68 | // Negative tests. | |
69 | static_assert(test_relationship<is_base_of, int, int>(false), ""); | |
70 | static_assert(test_relationship<is_base_of, EnumType, EnumType>(false), ""); | |
71 | static_assert(test_relationship<is_base_of, UnionType, UnionType>(false), ""); | |
72 | static_assert(test_relationship<is_base_of, int, const int>(false), ""); | |
73 | static_assert(test_relationship<is_base_of, volatile UnionType, | |
74 | UnionType>(false), ""); | |
75 | static_assert(test_relationship<is_base_of, int&, ClassType>(false), ""); | |
76 | static_assert(test_relationship<is_base_of, AbstractClass, | |
77 | ClassType>(false), ""); | |
78 | static_assert(test_relationship<is_base_of, ClassType, | |
79 | AbstractClass>(false), ""); | |
80 | static_assert(test_relationship<is_base_of, DerivedType, | |
81 | ClassType>(false), ""); | |
82 | static_assert(test_relationship<is_base_of, DerivedPolymorphic, | |
83 | PolymorphicClass>(false), ""); | |
84 | static_assert(test_relationship<is_base_of, DerivedHiddenCons, | |
85 | HiddenCons>(false), ""); | |
86 | static_assert(test_relationship<is_base_of, MultiDerivedHiddenCons, | |
87 | HiddenCons>(false), ""); | |
88 | static_assert(test_relationship<is_base_of, MultiDerivedHiddenCons, | |
89 | ClassType>(false), ""); | |
90 | } |