Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Move/copy assignment issue in 15.0

x_x_
Beginner
488 Views

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?

0 Kudos
1 Solution
TimP
Honored Contributor III
488 Views

Do previous posts on this question, e.g. https://software.intel.com/en-us/forums/topic/496266 shed any light?  You would need to report your specific g++ or MSVC version and options used to go anywhere with this.

View solution in original post

0 Kudos
3 Replies
TimP
Honored Contributor III
489 Views

Do previous posts on this question, e.g. https://software.intel.com/en-us/forums/topic/496266 shed any light?  You would need to report your specific g++ or MSVC version and options used to go anywhere with this.

0 Kudos
TimP
Honored Contributor III
488 Views

My reply was accepted but didn't show up.  Sorry if this duplicates.

I don't want to repeat previous discussions, e.g.

https://software.intel.com/en-us/forums/topic/496266

You didn't say whether you have an MSVC or g++ which supports your usage.

0 Kudos
x_x_
Beginner
488 Views

Hi Tim,

yes, the post you mention does shed light.

I use MSVC2013 and the November CTP compiler. This combination implicitly generates the move assignment operator.

Switching to the Intel compiler with "CTP_Nov2013" base platform toolset does not work, but now I know that this is intentional.

The hidden compiler switch is the solution.

Thank you, Tim.

0 Kudos
Reply