Debian Codegraph @

gcc/testsuite/g++.dg/overload/pmf3.C

raw
1 // PR c++/65880
2
3 class Test
4 {
5 public:
6 Test();
7 ~Test();
8
9 bool barl(void);
10
11 private:
12 bool fool(bool (Test::* const *fms)(void));
13 bool foo(void);
14 bool bar(void);
15 };
16
17 Test::Test()
18 {
19 }
20
21 Test::~Test()
22 {
23 }
24
25 bool Test::fool(bool (Test::* const *fms)(void))
26 {
27 bool retval = false;
28
29 int i = 0;
30 bool (Test::*f)(void) = fms[i++];
31
32 while (f) {
33 retval = (this->*f)();
34 if (retval) break;
35 f = fms[i++];
36 }
37
38 return retval;
39 }
40
41
42 bool Test::barl(void)
43 {
44 static bool (Test::* const fms[])(void) = {
45 &Test::foo,
46 &Test::bar,
47 0
48 };
49
50
51
52 return fool(fms);
53 }
54
55
56 bool Test::foo(void)
57 {
58 return false;
59 }
60
61 bool Test::bar(void)
62 {
63 return true;
64 }
65
66 int main(int argc, const char *argv[])
67 {
68 Test t;
69 return t.barl();
70 }