Quantcast
Channel: Intel® C++-Compiler
Viewing all articles
Browse latest Browse all 1665

Move/copy assignment issue in 15.0

$
0
0

Hi, surprisingly the following code generates an error:

#include <utility>

struct A

{

    A & operator=(A &&);

    A & operator=(A const &) = delete;

};

struct B

{

    A a;

};

int main()

{

    B b1, b2;

    b1 = std::move(b2); // calls B's implicitly-declared move assignment operator which should call A's move assignment operator

    return 0;

}

The error report is: function "A::operator=(const A &)" (declared at line 5) cannot be referenced -- it is a deleted function

The compiler wants to call A's copy assignment operator. I think this is not correct.

What do you think?


Viewing all articles
Browse latest Browse all 1665

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>