Debian Codegraph @

libstdc++-v3/testsuite/20_util/is_virtual_base_of/value.cc

raw
1 // { dg-do compile { target c++26 } }
2
3 #include <type_traits>
4
5 #if !defined(__cpp_lib_is_virtual_base_of) || __cpp_lib_is_virtual_base_of < 202406L
6 #error "__cpp_lib_is_virtual_base_of should have been defined to 202406L or more"
7 #endif
8
9 class B { };
10 class X : virtual public B { };
11 class Y : virtual public B { };
12 class Z : public B { };
13 class AA : public X, public Y, public Z { };
14
15 template<typename Base, typename Derived>
16 constexpr bool test()
17 {
18 constexpr bool t1 = std::is_virtual_base_of<Base, Derived>::value;
19 constexpr bool t2 = std::is_virtual_base_of_v<Base, Derived>;
20 static_assert(t1 == t2);
21 return t1;
22 }
23
24 void test01()
25 {
26 static_assert(!test<B, B>());
27 static_assert( test<B, X>());
28 static_assert( test<B, Y>());
29 static_assert(!test<B, Z>());
30 static_assert( test<B, AA>());
31 static_assert(!test<X, AA>());
32 static_assert(!test<Y, AA>());
33 static_assert(!test<Z, AA>());
34 }