Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constexpr-virtual11.C

raw
1 // P1064R0
2 // { dg-do compile }
3 // { dg-options "-std=c++2a" }
4
5 struct A
6 {
7 constexpr virtual int f () const { return 1; }
8 };
9
10 struct B : public A
11 {
12 constexpr virtual int f () const { return 2; }
13 };
14
15 struct C
16 {
17 A a;
18 B b;
19 };
20
21 constexpr C c;
22 constexpr const A &d = c.a;
23 constexpr const A &e = c.b;
24 constexpr const B &f = c.b;
25 static_assert (c.a.f () == 1 && c.b.f () == 2);
26 static_assert (d.f () == 1 && e.f () == 2 && f.f () == 2);