aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual22.C
blob: 89330bf86200aa9f7bfb81bbacb8a551160f0c43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// PR c++/117615
// { dg-do "compile" { target c++20 } }

struct Base {
    virtual void doit (int v) const {}
};

struct Derived : Base {
    void doit (int v) const {}
};

using fn_t = void (Base::*)(int) const;

struct Helper {
    fn_t mFn;
    constexpr Helper (auto && fn) : mFn(static_cast<fn_t>(fn)) {}
};

void foo () {
    constexpr Helper h (&Derived::doit);
    constexpr Helper h2 (&Base::doit);
}