================ @@ -512,24 +512,31 @@ namespace LambdaInDefaultMemberInitializer { } #if __cplusplus >= 201703L -namespace GH35052 { -template <typename F> constexpr int func(F f) { - if constexpr (f(1UL)) { - return 1; +namespace local_recursive_lambda { + +template <typename F> struct recursive_lambda { + template <typename... Args> auto operator()(Args &&...args) const { + return fn(*this, args...); } - return 0; -} + F fn; +}; -int main() { - auto predicate = [](auto v) /*implicit constexpr*/ -> bool { - return v == 1; - }; +template <typename F> recursive_lambda(F) -> recursive_lambda<F>; + +struct Tree { + Tree *left, *right; +}; + +int sumSize(Tree *tree) { + auto accumulate = + recursive_lambda{[&](auto &self_fn, Tree *element_node) -> int { + return 1 + self_fn(tree->left) + self_fn(tree->right); + }}; - static_assert(predicate(1)); - return func(predicate); + return accumulate(tree); } -} // namespace GH35052 +} // namespace local_recursive_lambda ---------------- cor3ntin wrote:
Can we leave a reference to the issue here? (also that test can be simplified) https://github.com/llvm/llvm-project/pull/98991 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits