-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add polymorphic value like container #855
feat: Add polymorphic value like container #855
Conversation
b5d9a03
to
4e50f99
Compare
Codecov Report
@@ Coverage Diff @@
## main #855 +/- ##
==========================================
+ Coverage 48.53% 48.65% +0.12%
==========================================
Files 329 330 +1
Lines 16974 17076 +102
Branches 8025 8053 +28
==========================================
+ Hits 8239 8309 +70
- Misses 3083 3089 +6
- Partials 5652 5678 +26
Continue to review full report at Codecov.
|
@HadrienG2 would you be available to review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
@paulgessinger how come the CI didn't try a build for this PR? It broke the build due to a missing |
#855 broke the build on my end because of a missing include in a test file. Here we simply add that include, and all is well.
This is needed to ensure G4 can have ownership of the detector constructions. This also makes the recently introduced polymorphic value container (#855) obsolete, so this removes it
This PR introduces a type
PolymorphicValue<T>
that behaves very similar tostd::unique_ptr<T>
, but preserves knowlegde of how to copy the value. In fact,PolymorphicValue
only works with copyable types.This allows more convenient handling of interfaces, for types that are copyable and where copying does not have to be avoided.
It looks like this:
The reason why I'm adding this is that
pybind11
does not supportstd::unique_ptr
as arguments/values on the C++ side, since python lacks a mechanism to release ownership, which would be required in this case. There's a limited number of cases where this is a problem, and where we don't actually care if we copy the stored value.WIP until I finalize this.