Skip to content
Snippets Groups Projects

Make assignment operators consistent with standard signature

This is needed to support conditionally trivially copyable Matrix and Array when they are fixed-sized, which require explicitly defaulted trivial copy assignment operators for all their base classes. But the defaulted copy assignment operators have different return types than those of the current non-trivial copy assignment operators, resulting in implicit inconsistency and potentially hard to debug behaviors.

Therefore make the non-trivial copy assignment operators of all the base classes return consistent types with the trivial ones. To ensure consistency, all other simple assignment operators are also changed in the same way.

This is an API breaking change:

Assignment operators of some Eigen classes used to return Derived&. Now assignment operators of every classes return references to the class itself.

Chained calls that use the return type of assignment operators, e.g. (x = y).foo() or return x = y; should be updated to explicitly use the most specific derived type, e.g. (x = y).derived().foo() or x = y; return x;.

Edited by Lingzhu Xiang

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Antonio Sánchez added 38 commits

    added 38 commits

    • b26178b7...baf9a985 - 37 commits from branch libeigen:master
    • ea64ec03 - Make copy assignment operators consistent with standard signature

    Compare with previous version

  • added 11 commits

    • ea64ec03...9deaa191 - 10 commits from branch libeigen:master
    • e388ae07 - Make copy assignment operators consistent with standard signature

    Compare with previous version

  • Lingzhu Xiang added 2 commits

    added 2 commits

    • 261324b8 - Make copy assignment operators consistent with standard signature
    • 24517e7d - Change all X::operator=() to return X&

    Compare with previous version

  • Lingzhu Xiang resolved all threads

    resolved all threads

  • Author Contributor

    Changes from last version:

    • All (need reviews to check for missed cases) X::operator()= cases are changed to return X&, except that SymbolExpr::operator=() returns SymbolValue<Tag>. This is an exception that cannot be changed to return SymbolExpr&.
    • Quite a few cases of Derived& Foo() { return operator=(...); } that encounters problems converting the operator=() returned Base& to Derived&. All are changed to operator=(...); return *this; or operator=(...); return derived(); avoiding chaining assignment and return. (Need reviews to check for missed cases)
    • Added test helpers to fix usage of VERIFY(x.noalias() = y, ...) since NoAlias::operator=() now returns NoAlias.
  • Lingzhu Xiang changed title from Make copy assignment operators consistent with standard signature to Make assignment operators consistent with standard signature

    changed title from Make copy assignment operators consistent with standard signature to Make assignment operators consistent with standard signature

  • Lingzhu Xiang changed the description

    changed the description

  • added 21 commits

    • 24517e7d...0c859cf3 - 19 commits from branch libeigen:master
    • 6cd2456c - Make copy assignment operators consistent with standard signature
    • 1e7285be - Change all X::operator=() to return X&

    Compare with previous version

  • added 27 commits

    • 1e7285be...9e026e5e - 25 commits from branch libeigen:master
    • 93a17b56 - Make copy assignment operators consistent with standard signature
    • 48f2f97a - Change all X::operator=() to return X&

    Compare with previous version

  • Friendly ping on this, would be great to unblock the rest of the work for making Vector trivially_copyable #1855

  • @cantonios do you need help with this?

  • added 6 commits

    • 48f2f97a...73d65dbc - 4 commits from branch libeigen:master
    • 06e837be - Make copy assignment operators consistent with standard signature
    • a2202877 - Change all X::operator=() to return X&

    Compare with previous version

  • Antonio Sánchez resolved all threads

    resolved all threads

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading