C++ Logo


Advanced search

Re: Deleting the Rvalue member function

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 30 Dec 2022 15:44:18 +0000
On Friday, December 30, 2022, Jason McKesson via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> `= delete` as applied to an rvalue `this` overload would be done to
> prevent someone from calling that function with an rvalue.

To achieve this behaviour, it's better to define the unary '&' operator
with an ampersand at the end of it:

    MyClass *operator&(void) &;

And so we could make it a compiler error to delete the && one.

Received on 2022-12-30 15:44:20