Your "functions" are not just functions, but class methods. It is not clear from your question for which object you are going to call these class methods.
for example
std::list<std::function<void(bool)>> listFunc;
and further
listFunc.push_back(std::bind(&A::f0, this, std::placeholders::_1)); listFunc.push_back(std::bind(&A::f1, this, std::placeholders::_1)); listFunc.push_back(std::bind(&A::f2, this, std::placeholders::_1));
or through lambda
listFunc.push_back([this](bool b) { f0(b); }); listFunc.push_back([this](bool b) { f1(b); }); listFunc.push_back([this](bool b) { f2(b); });
Call
listFunc.front()(false);
In this embodiment, the binding of a specific object ( this ) is done at the time of filling the list.
You can do the same
std::list<void (A::*)(bool)> listFunc;
Further
listFunc.push_back(&A::f0); listFunc.push_back(&A::f1); listFunc.push_back(&A::f2);
But the challenge then will be
(a.*listFunc.front())(false);
In this embodiment, specifying a particular object ( a ) is done at the time of the call.
The use of std::function in the first version introduces unnecessary overhead, in many cases completely unjustified. But due to the fact that neither the type of std::bind , nor the type of lambda in C ++ is uniquely defined, one has to use std::function willy-nilly. (In this respect, the outdated std::bind1st was better.)
A more efficient alternative to the first option may be a "manual" implementation.
struct Af { A *self; void (A::*f)(bool); void operator ()(bool b) const { (self->*f)(b); } };
and further
std::list<Af> listFunc; ... listFunc.push_back({ this, &A::f0 }); listFunc.push_back({ this, &A::f1 });
and challenge
listFunc.front()(false);
f0,f1,f2? - AnT 3:32 pmthisobject. Moreover, this object will be in a single copy. - Kto To