Debian Codegraph @

gcc/testsuite/g++.dg/template/friend80.C

raw
1 // PR c++/112288
2 // { dg-do compile { target c++11 } }
3
4 template<class T>
5 struct slot {
6 template<class U>
7 friend constexpr bool slot_allocated(slot<T>, U);
8 };
9
10 template<class T>
11 struct allocate_slot {
12 template<class U>
13 friend constexpr bool slot_allocated(slot<T>, U) { return true; }
14 };
15
16 template<class T, bool = slot_allocated(slot<T>{}, 42)>
17 constexpr int next(int) { return 1; }
18
19 template<class T>
20 constexpr int next(...) { return (allocate_slot<T>{}, 0); }
21
22 // slot_allocated<slot<int>, int>() not defined yet
23 static_assert(next<int>(0) == 0, "");
24 // now it's defined, need to make existing spec point to defn or else ICE
25 static_assert(next<int>(0) == 1, "");