Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule A12-8-4 and default constructing data members in a move constructor
#1
Quoting the rationale of this A12-8-4:
Quote:Data members or base classes initialization in move constructor needs to be done with move semantics.
Does this mean that in order to comply with the rule, all data members in a move constructor must be initialized with move semantics, and thus no data members may be default constructed in a move constructor?
The text of the rule does not go that far, it merely prevents the use of copy semantics in move constructors.
Reply
#2
I should add some additional context. In a constructor, we want to construct a data member in the constructor member initializer list, and the move assign to it in the function body of the constructor. Is this in compliance with the rule or is it breaking the rule because the data member is not initialized using move semantics?
Reply
#3
We agree the intent of 12-8-4 was to prevent calls made to copy constructors and/or copy assignment operators, so you are compliant.

However, what you are proposing violates the spirit of the rationale for 12-8-4, and may be a violation of other rules.
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)