summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/overload/pmf3.C
blob: a71f554441b96eab9c2e1eb0b8f1c7732e19974f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// PR c++/65880

class Test
{
  public:
    Test();
    ~Test();

    bool barl(void);

  private:
    bool fool(bool (Test::* const *fms)(void));
    bool foo(void);
    bool bar(void);
};

Test::Test()
{
}

Test::~Test()
{
}

bool Test::fool(bool (Test::* const *fms)(void))
{
    bool retval = false;

    int i = 0;
    bool (Test::*f)(void) = fms[i++];

    while (f) {
        retval = (this->*f)();
        if (retval) break;
        f = fms[i++];
    }

    return retval;
}


bool Test::barl(void)
{
    static bool (Test::* const fms[])(void) = {
        &Test::foo,
        &Test::bar,
        0
    };



    return fool(fms);
}


bool Test::foo(void)
{
    return false;
}

bool Test::bar(void)
{
    return true;
}

int main(int argc, const char *argv[])
{
    Test t;
    return t.barl();
}