gcc/testsuite/g++.dg/cpp2a/constexpr-virtual22.C
raw| 1 | // PR c++/117615 |
| 2 | // { dg-do "compile" { target c++20 } } |
| 3 | |
| 4 | struct Base { |
| 5 | virtual void doit (int v) const {} |
| 6 | }; |
| 7 | |
| 8 | struct Derived : Base { |
| 9 | void doit (int v) const {} |
| 10 | }; |
| 11 | |
| 12 | using fn_t = void (Base::*)(int) const; |
| 13 | |
| 14 | struct Helper { |
| 15 | fn_t mFn; |
| 16 | constexpr Helper (auto && fn) : mFn(static_cast<fn_t>(fn)) {} |
| 17 | }; |
| 18 | |
| 19 | void foo () { |
| 20 | constexpr Helper h (&Derived::doit); |
| 21 | constexpr Helper h2 (&Base::doit); |
| 22 | } |