C++ Logo

std-discussion

Advanced search

Re: Deleting the Rvalue member function

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Tue, 27 Dec 2022 17:51:41 +0000
Hi,

On 27 December 2022 13:32:23 GMT, Frederick Virchanza Gotham via Std-Discussion <std-discussion_at_[hidden]> wrote:
>What's the compiler supposed to do here?
>
>struct Dog {
> Dog const volatile *operator&(void) const volatile && = delete;
>};
>
>#include <iostream>
>using std::cout;
>using std::endl;
>#include <utility>
>using std::move;
>
>int main(void)
>{
> Dog d;
>
> d.operator&(); // Should this work?
> move(d).operator&(); // I don't think this should work
>}

The first call does not find a viable operator&, therefore that is ill-formed. The second call finds the deleted operator&, so that's also ill-formed.

Is there any relevance that you are using operator& here, instead of just a regular member function?

Cheers,
Lénárd

Received on 2022-12-27 17:51:46