The purpose of CreateFunctor in the post you cite is to create a function object which binds the arguments to the lambda at the time of construction.
You do this in the call to CreateFunction, but you also pass the arguments again when you call the function object.
Because the arguments are already bound, this is un-necessary (and indeed not possible).
Simply call f1().
Comment: the post cited seeks to improve the performance of a bound function object over that already provided by std::function. I suspect the author is prematurely optimising. Std::function already has performance optimisations built in.
EDIT: of found the code at the end of the link
The compiler error message is quite explicit:
./functor.cpp:57:5: error: type 'Functor<int, int>' does not provide a call operator
The problem is here:
template<class... Args> struct Functor{
Functor(void (*)(Args...)) {std::cout << "Functor\n" << std::endl;}
void Set(Args...) {std::cout << "Set\n" << std::endl;}
};
The Functor
template class is incomplete. It does not have a call operator defined (as per the error message).
Why not save yourself the trouble and use the standard objects?
auto f1 = std::function([] { do_something(1, 2); });
f1();
or
auto f1 = std::function([a = 1, b = 2]{ do_something(a,b); });