I'd like to call a lambda with const template value, in example below I should write lambdaTemplate correctly
#include <iostream> using namespace std; template<int bar, int baz> int foo(const int depth) { return bar + baz + depth; } int main() { ////// call function cout << foo<1, 2>(10) << endl; // 13 ///// call lambda without template value const auto lambda1 = [&](const int v) { return foo<1, 2>(v); }; cout << lambda1(10) << endl; // 13 ///// call lambda with template value const auto lambdaTemplate = [&]<A,B ??? >(const int v) { // <-- ERROR doesn't compile return foo<A,B>(v); }; cout << lambdaTemplate<1,2>(10) << endl; return 0; }
foo.lambdaTemplate<1,2>(10), that's a non-starter.lambdaTemplate(constant<1>, constant<2>)(10)to work, however.