view gcc/testsuite/g++.dg/overload/pmf3.C @ 138:fc828634a951

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:17:14 +0900
parents 04ced10e8804
children
line wrap: on
line source

// 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();
}