Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
249 views
Welcome To Ask or Share your Answers For Others

1 Answer

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...