#include <utility>
using namespace std;
template<class Func, class... Args>
auto test_lambda(Func&& func, Args&&... args) {
return [=]() mutable { func(std::move(args)...); };
}
void test_int(int*){}
int main() {
int arr[5];
test_lambda(test_int, arr);
}
I2luY2x1ZGUgPHV0aWxpdHk+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0ZW1wbGF0ZTxjbGFzcyBGdW5jLCBjbGFzcy4uLiBBcmdzPgphdXRvIHRlc3RfbGFtYmRhKEZ1bmMmJiBmdW5jLCBBcmdzJiYuLi4gYXJncykgewogICAgcmV0dXJuIFs9XSgpIG11dGFibGUgeyBmdW5jKHN0ZDo6bW92ZShhcmdzKS4uLik7IH07Cn0KCnZvaWQgdGVzdF9pbnQoaW50Kil7fQoKaW50IG1haW4oKSB7CiAgICBpbnQgYXJyWzVdOwogICAgdGVzdF9sYW1iZGEodGVzdF9pbnQsIGFycik7Cn0=
prog.cpp: In instantiation of 'test_lambda(Func&&, Args&& ...)::<lambda()> mutable [with Func = void (&)(int*); Args = {int (&)[5]}]':
prog.cpp:6:43: required from 'struct test_lambda(Func&&, Args&& ...) [with Func = void (&)(int*); Args = {int (&)[5]}]::<lambda()>'
prog.cpp:6:54: required from 'auto test_lambda(Func&&, Args&& ...) [with Func = void (&)(int*); Args = {int (&)[5]}]'
prog.cpp:13:30: required from here
prog.cpp:6:28: error: variable 'func' has function type
return [=]() mutable { func(std::move(args)...); };
^
prog.cpp:6:28: error: variable 'func' has function type
prog.cpp: In instantiation of 'struct test_lambda(Func&&, Args&& ...) [with Func = void (&)(int*); Args = {int (&)[5]}]::<lambda()>':
prog.cpp:6:54: required from 'auto test_lambda(Func&&, Args&& ...) [with Func = void (&)(int*); Args = {int (&)[5]}]'
prog.cpp:13:30: required from here
prog.cpp:6:28: error: field 'test_lambda(Func&&, Args&& ...) [with Func = void (&)(int*); Args = {int (&)[5]}]::<lambda()>::<func capture>' invalidly declared function type