Template argument and deduction of std::function parameters
问题 Assume there is a template function foo() which accepts an arbitrary number of arguments. Given the last argument is always an std::function , how do I implement a foo() template shown below in a way that CbArgs would contain this std::function 's parameters? template<typename... InArgs, typename... CbArgs = ???> // ^^^^^^^^^^^^ void foo(InArgs... args) { ... } For example, CbArgs should be {int,int} if invoked like this: std::function<void(int,int)> cb; foo(5, "hello", cb); My first idea was