Debian Codegraph @

gcc/testsuite/g++.dg/ext/bases.C

raw
1 // { dg-options "-w" }
2 // { dg-do run { target c++11 } }
3 // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } }
4
5 #include<typeinfo>
6 #include<cassert>
7
8 // A simple typelist
9 template<typename... _Elements> struct types {};
10
11 // Simple bases implementation
12 template<typename T> struct b {
13 typedef types<__bases(T)...> type;
14 };
15
16 // Simple direct_bases implementation
17 template<typename T> struct db {
18 typedef types<__direct_bases(T)...> type;
19 };
20
21 template <class,class> struct assert_same_type;
22 template <class T> struct assert_same_type<T,T> {};
23
24 struct A {};
25 struct C : virtual A {};
26 struct D : public C {};
27 struct B : D, virtual A {};
28 struct E : C, virtual D, B {};
29 struct F : A, B, E {};
30
31 int main() {
32 assert_same_type<b<F>::type, types<A,C,D,A,C,D,B,C,C,D,B,E>>();
33 assert_same_type<db<F>::type, types<A,B,E>>();
34 assert_same_type<db<int>::type, types<>>();
35 return 0;
36 }