Skip to content

Commit

Permalink
fix: Enable copyFrom const track proxy for MultiTrajectory (#1127)
Browse files Browse the repository at this point in the history
This adds a `friend class` statement in the `MultiTrajectory` that enables `copyFrom(...)` from a `ConstTrackStateProxy` to a mutable `TrackStateProxy`.

I added this to the UnitTest, but this for now only checks if this compiles.
  • Loading branch information
benjaminhuth committed Dec 17, 2021
1 parent adcd2b5 commit 486d6fe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ class TrackStateProxy {

friend class Acts::MultiTrajectory;
friend class TrackStateProxy<M, true>;
friend class TrackStateProxy<M, false>;
};

// implement track state visitor concept
Expand Down
19 changes: 19 additions & 0 deletions Tests/UnitTests/Core/EventData/MultiTrajectoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,4 +868,23 @@ BOOST_AUTO_TEST_CASE(ProxyAssignment) {
// MultiTrajectory::TrackStateProxy tp4{tp3};
}

// Check if the copy from const does compile, assume the copy is done correctly
BOOST_AUTO_TEST_CASE(CopyFromConst) {
using PM = TrackStatePropMask;
MultiTrajectory mj;

const auto idx_a = mj.addTrackState(PM::All);
const auto idx_b = mj.addTrackState(PM::All);

MultiTrajectory::TrackStateProxy mutableProxy = mj.getTrackState(idx_a);

const MultiTrajectory& cmj = mj;
MultiTrajectory::ConstTrackStateProxy constProxy = cmj.getTrackState(idx_b);

mutableProxy.copyFrom(constProxy);

// copy mutable to const: this won't compile
// constProxy.copyFrom(mutableProxy);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 486d6fe

Please sign in to comment.