Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/var-templ77.C

raw
1 // PR c++/107939
2 // { dg-do compile { target c++14 } }
3
4 struct Q {
5 struct P {
6 const Q* p;
7 };
8 int n;
9 constexpr P operator()(int) const { return {this}; }
10 };
11
12 extern const Q q;
13 template<int>
14 constexpr auto p = q(0);
15 static_assert(p<0>.p == &q, "");
16
17 constexpr int
18 fn (int)
19 {
20 return 42;
21 }
22
23 struct Sur {
24 using FN = int(int);
25 constexpr operator FN*() const { return &fn; }
26 };
27
28 extern const Sur sur;
29 template<int>
30 constexpr int aja = sur (0);
31 static_assert(aja<0> == 42, "");
32 static_assert(sur(1) == 42, "");