C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] proposal: new const-able feature ( use "const?" , or new "constable" keyword) for method/function
From: Michael Hava (mfh_at_[hidden])
Date: 2019-12-16 15:15:05


optional<Type> func() { return Type{}; }
Type t = *func(); //trigger move of contained object as operator* is aware of r-refness of this and moves value out...

See: https://en.cppreference.com/w/cpp/utility/optional/operator*

From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of jianping z via Std-Proposals
Sent: Monday, December 16, 2019 10:07 PM
To: Barry Revzin <barry.revzin_at_[hidden]>; std-proposals_at_[hidden]
Cc: jianping z <zjpwork_at_[hidden]>
Subject: Re: [std-proposals] proposal: new const-able feature ( use "const?" , or new "constable" keyword) for method/function


also, for your example, do we really need following 2 member methods returning value of type "T&&" and "const T&&"?

    auto operator*() && -> T&& { return std::move(value); }
    auto operator*() const&& -> T const&& { return std::move(value); }

do you have code example to show the possible usage of these 2 methods?

Best Regards,



STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups