I'm trying to accept multiple arguments in a std::function
, but I got errors:
#include <functional>
template <typename... Args>
void caller(std::function<void(Args&&...)> function)
{
}
int main()
{
caller([&] () { });
}
The error is:
main.cpp:11:22: error: no matching function for call to 'caller(main()::<lambda()>)'
caller([&] () { });
^
main.cpp:11:22: note: candidate is:
main.cpp:4:6: note: template<class ... Args> void caller(std::function<void(Args&& ...)>)
void caller(std::function<void(Args&&...)> function)
^
main.cpp:4:6: note: template argument deduction/substitution failed:
main.cpp:11:22: note: 'main()::<lambda()>' is not derived from 'std::function<void(Args&& ...)>'
caller([&] () { });
How can I make this work?