Skip to content

Comment on Curious C++ Lambda Examples: Recursion, constexpr, Containers C++23 includedparent

Comments

Because `this auto&&` was not introduced to allow for recursive lambads. That's just a happy (though not very interesting) side effect. It was introduced so that you don't have to write duplicated code such as:

    class Awesome {
        // ...
        foo& my_method() { /* ... */ }    
        const foo& my_method() const { /* ... */ }
    };
and the extra duplication for lvalues and rvalues.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.