C++ Logo

std-proposals

Advanced search

[std-proposals] Enforce const correctness on deleted move constructor

From: Smith, Jim <jim.smith_at_[hidden]>
Date: Sat, 02 Dec 2023 20:46:36 +0000
Hi,

Example:
class A {
public:
...
A(const A&&) = delete ;
...
};

The above deleted move constructor with const signature should not delete the default move constructor with non-const signature A(A&&) as the compiler error says for the following code:

A x;
A a = std::move(x);

compiler: note: 'A' has been explicitly marked deleted here
A(const A&&) = delete;

In this case an implicit default non-const move constructor should be called unless it's also deleted.

-- James S.

Received on 2023-12-02 20:46:53