lundi 25 septembre 2017

Segmentation fault when calling member function using std::function

I dont have much experience with std::bind or std::function so there may be a lot of basic errors.

I am trying to store a function as a member of class foo which stores another member function from another class. The only things known are function parameters.

Class foo (example)

class foo{
private:
    someMembers;
public
    std::function<void(task*)> task_routine; //temporary. Will be encapsulated after its working like this
    someMoreMembersConstructorsetc;
}

Here is a example for another class:

class anotherClass{
private:
    void task_routine_default(task*){
        someStuffThatUsesThis->;
    }
private:
    anotherClass(someParameters){
        .
        .
        .
        foo f1();
        f1.task_routine = std::bind(&anotherClass::task_routine_default,&*this,std::placeholders::_1);
        .
        .
        .
    }
}

there is also another class. All it does it keep the class foo and calls the function stored...

What exactly is the problem here?

Aucun commentaire:

Enregistrer un commentaire