mardi 25 août 2015

could not convert ... from '

I'm trying to fix a specific failure now for about two hours and I'm done with my knowledge. Any Ideas?

The Failure:

could not convert '{{TEST1, (& ffm::cond_test1)}, {TEST2, (& ffm::cond_test2)}}' from '<brace-enclosed initializer list>' to 'std::map<ffm::conditions, bool (*)()>'

The code:

#include <map>
#include <iostream>

namespace ffm {
    typedef bool (*condFunction)();

    enum conditions {
        TEST1 = 0,
        TEST2
    };

    bool cond_test1();
    bool cond_test2();
}

using namespace ffm;

bool cond_test1()
{
    std::cout << "cond_test1 is always TRUE" << std::endl;
    return true;
}

bool cond_test2()
{
    std::cout << "cond_test2 is always FALSE" << std::endl;
    return false;
}

int main() {
    std::map<conditions, condFunction> condFuncMap = { 
        {conditions::TEST1, &cond_test1}, 
        {conditions::TEST2, &cond_test2} };

}

I'm using gcc4.8.4

Aucun commentaire:

Enregistrer un commentaire