Community
cancel
Showing results for 
Search instead for 
Did you mean: 
x_x_
Beginner
47 Views

Move/copy assignment issue in 15.0

Jump to solution

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

Accepted Solutions
TimP
Black Belt
47 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
48 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

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