:4:13: error: function 'operator()' with deduced return type cannot be used before it is defined
4 | self(n - 1);
| ^
:8:7: note: in instantiation of function template specialization 'main()::(anonymous class)::operator()' requested here
8 | fn(3);
| ^
:2:15: note: 'operator()' declared here
2 | auto fn = [](this auto&& self, T n) {
| ^
1 error generated.
Compiler returned: 1
См. https://godbolt.org/z/pybm8w9rv
Почему рекурсивный лямбда с параметрами шаблона и аргументом Decucing (this) не работает?>
[code]int main() { auto fn = [](this auto&& self, T n) { if (n > 0) { self(n - 1); } };
fn(3); } [/code] Скомпилировано с Clang -20 -Std = c ++ 23 , но получил следующие ошибки: [code]:4:13: error: function 'operator()' with deduced return type cannot be used before it is defined 4 | self(n - 1); | ^ :8:7: note: in instantiation of function template specialization 'main()::(anonymous class)::operator()' requested here 8 | fn(3); | ^ :2:15: note: 'operator()' declared here 2 | auto fn = [](this auto&& self, T n) { | ^ 1 error generated. Compiler returned: 1 [/code] См. https://godbolt.org/z/pybm8w9rv Почему рекурсивный лямбда с параметрами шаблона и аргументом Decucing (this) не работает?>