Skip to content

[Core] Introduce WriteAccessor move constructor#6032

Open
alxbilger wants to merge 3 commits intosofa-framework:masterfrom
alxbilger:writeaccessormove
Open

[Core] Introduce WriteAccessor move constructor#6032
alxbilger wants to merge 3 commits intosofa-framework:masterfrom
alxbilger:writeaccessormove

Conversation

@alxbilger
Copy link
Contributor

@alxbilger alxbilger commented Mar 18, 2026

It allows to write such code:

sofa::type::vector<sofa::helper::WriteAccessor<InDataMatrixDeriv> > outAccessors;
outAccessors.reserve(dOut.size());
for (auto* out : dOut)
{
    outAccessors.emplace_back(out);
}

[with-all-tests]


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@alxbilger alxbilger added pr: enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request labels Mar 18, 2026
@fredroy
Copy link
Contributor

fredroy commented Mar 19, 2026

I wonder what should/will happen if one use the moved thing after the move (std::move and stuff) ? 🤔

@th-skam th-skam added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Mar 19, 2026
@alxbilger
Copy link
Contributor Author

I wonder what should/will happen if one use the moved thing after the move (std::move and stuff) ? 🤔

According to the unit tests, the accessor stays valid but does not trigger endEdit. Note that clang-tidy triggers a warning in this case: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: enhancement About a possible enhancement pr: status ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants