• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Expected move_assignment to be deleted

Resolved: Expected move_assignment to be deleted

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I’m trying to write a wrapper class that conditionally disables four special member functions (copy construct, move construct, copy assignment and move assignment), below is a quick draft I used for testing purposes:
The above code functions correctly, except for three cases (<move_ctor, move_asgn>, <copy_ctor, move_asgn> and <copy_ctor, move_ctor, move_asgn>). Specifically, the assertion in the code below fails, which leads me to believe that for some reason the defaulted move assignment operator is not deleted, in the move_ctor partial specialisation of _disabled_wrapper, even though its non-static member _parent has its move assignment deleted. cppreference.com states:

The implicitly-declared or defaulted move assignment operator for class T is defined as deleted if any of the following is true: T has a non-static data member that is const; T has a non-static data member of a reference type; T has a non-static data member that cannot be move-assigned (has deleted, inaccessible, or ambiguous move assignment operator); T has direct or virtual base class that cannot be move-assigned (has deleted, inaccessible, or ambiguous move assignment operator). A deleted implicitly-declared move assignment operator is ignored by overload resolution.


Which makes me believe that, according to the standard, the move assignment operator should indeed be deleted (bullet point three). What am I missing and or, if possible, how do I make the wrapper class work as intended without manually typing all possible specialisations? Thank you.

Answer:

The last statement in your quote “A deleted implicitly-declared move assignment operator is ignored by overload resolution.” is more precisely:

A defaulted move assignment operator that is defined as deleted is ignored by overload resolution.


class.copy.assign
type has a defaulted move assignment operator which is defined as deleted because it is deleted in a base class.
Therefore, this operator is ignored by overload resolution.
Therefore, assignment from an rvalue selects copy assignment.
Therefore, type is move assignable because it is copy assignable.

If you have better answer, please add a comment about this, thank you!

c++ metaprogramming
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Is pandas groupby() function always produce a DataFrame with the same order respect to the column we group by?

24/03/2023

Resolved: Kivy widget hierarchy not behaving as expected

24/03/2023

Resolved: Pandas Groupby Get Values from Previous Group

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.