Date: Mon, 16 Dec 2019 21:15:05 +0000
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]cpp.org> 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,
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]cpp.org> 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,
Received on 2019-12-16 15:17:33