1 | struct ContextClass { |
2 | int member = 3; |
3 | ContextClass *this_type = nullptr; |
4 | ContextClass() { this_type = this; } |
5 | |
6 | int func() const { |
7 | return member; // break in function in class. |
8 | } |
9 | |
10 | template <class T> T templateFunc(T x) const { |
11 | return member; // break in templated function in class. |
12 | } |
13 | }; |
14 | |
15 | template <typename TC> struct TemplatedContextClass { |
16 | int member = 4; |
17 | TemplatedContextClass<TC> *this_type = nullptr; |
18 | TemplatedContextClass() { this_type = this; } |
19 | |
20 | int func() const { |
21 | return member; // break in function in templated class. |
22 | } |
23 | |
24 | template <class T> T templateFunc(T x) const { |
25 | return member; // break in templated function in templated class. |
26 | } |
27 | }; |
28 | |
29 | int main() { |
30 | ContextClass c; |
31 | TemplatedContextClass<int> t; |
32 | return c.func() + c.templateFunc(x: 1) + t.func() + t.templateFunc(x: 1); |
33 | } |
34 | |