std::function does weird things

Hey,

is there any problem with inheritance and std::function?
because adding std::function to a my child class corrupts my code.
I have no idea how,where and when but adding just the declaration std::function<void()> test;

is enough to break everything.

example:

class Timer : public ITickable
{
std::function<void()> test; //adding this does weird things

virtual void Tick() {}
}

class MyClass
{
ITickable* tickable_;

void Tick()
{
tickable_->Tick(); //let's assume it points to a Timer obj.
}
}
Last edited on
You need to provide temlate parameters for function: what it returns and what it takes. Like:
std::function<void(int)> test;
i did, but forgot to write it here, but the problem is still the same.
How is it corrupting your code? Compete minimal example if possible. Even better, a link to online compiler page showing problem would be cool. http://coliru.stacked-crooked.com/
ok there was no problem with std::function, a clean did the job, and now everything works ....
Topic archived. No new replies allowed.