]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/tr2/bases/value.cc
1 // { dg-do run { target c++11 } }
2 // { dg-require-effective-target rtti }
4 // Copyright (C) 2011-2024 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <tr2/type_traits>
26 struct B1
: virtual public A
{ };
27 struct B2
: virtual public A
{ };
28 struct C
: public B1
, public B2
{ };
34 typedef std::tr2::bases
<A
>::type tl
;
35 static_assert(tl::empty::value
, "error");
40 typedef std::tr2::bases
<B1
>::type tl1
;
41 typedef std::tr2::bases
<B2
>::type tl2
;
43 // Sanity check w/ runtime.
44 bool eq
= typeid(tl1
) == typeid(tl2
);
46 throw std::logic_error("typelist not equal");
49 static_assert(tl1::empty::value
!= std::true_type::value
, "!empty");
50 static_assert(tl2::empty::value
!= std::true_type::value
, "!empty");
52 typedef tl1::first::type tl1_first
;
53 typedef tl1::rest::type tl1_rest
;
54 typedef tl2::first::type tl2_first
;
55 typedef tl2::rest::type tl2_rest
;
57 eq
= typeid(tl1_first
) == typeid(tl2_first
);
59 throw std::logic_error("base not equal");
61 static_assert(tl1_rest::empty::value
== std::true_type::value
, "empty");
62 static_assert(tl2_rest::empty::value
== std::true_type::value
, "empty");
67 typedef std::tr2::bases
<C
>::type tl
;
70 static_assert(tl::empty::value
!= std::true_type::value
, "!empty");
72 typedef tl::first::type tl1_first
;
73 typedef tl::rest::type tl2
;
74 typedef tl2::first::type tl2_first
;
75 typedef tl2::rest::type tl3
;
76 typedef tl3::first::type tl3_first
;
77 typedef tl3::rest::type tl4
;
79 bool eq
= typeid(tl1_first
) == typeid(tl2_first
);
81 throw std::logic_error("bases are not equal");
83 eq
= typeid(tl2_first
) == typeid(tl3_first
);
85 throw std::logic_error("bases are not equal");
87 static_assert(tl4::empty::value
== std::true_type::value
, "empty");