Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.

Move/copy assignment issue in 15.0

x_x_
Beginner
150 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
Black Belt
150 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

3 Replies
TimP
Black Belt
151 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.

TimP
Black Belt
150 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.

x_x_
Beginner
150 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.

Reply