check
itself is not a template. It is an object, of an unspecified closure type, that contains
template<auto I> void operator()();
The member function is the template.
The error is due to the attempt at supplying template arguments to check
. Which is not a template itself, again. The template parameters of a lambda's function call operator need to be deducible (even if they are named), for the function call syntax to work. That hasn't changed with C++20.
The only way to specify the parameters explicitly is the pretty ugly
check.template operator()<II>()
But instead it may be better to make it deducible.
[&]<auto... II>(std::index_sequence<II...>) {
auto check = [&]<auto I>(std::integral_constant<decltype(I), I>){
};
(check(std::integral_constant<decltype(II), II>{}),...);
}(std::make_index_sequence<N>{});
Specifying size_t
explicitly is also an option instead of using decltype(I)
.