Does C++11 provide delegates?
If not, what is the best (most efficient) way to do something similar in C++? Boost.Signals? FastDelegate? Something else?
You don't necessarily need to wait for C++0x. You can implement Delegates almost as well in the current C++03 standard.
You simply have to overload the operator (), so as you can call MyObjectFunctor functor; functor();
and since the functor is an object, you can pass it as a delegate/object into functions;
the current version of the STL defines the header
that provides functions ready to be used with Functors/Lambdas/Delegates.
simple example of a functor.
struct FunctorDelegate
{
// as so to delegate as a function that takes an int input
void operator()(int)
{
// do what I want
}
};
int main()
{
//... do some stuffs with an std::vector aRange;
FunctorDelegate functor;
std::for_each(aRange.begin(), arange.end(), functor);
}