-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Let edm::Wrapper<T>
use the constructor T{kUninitialized}
#46877
Merged
cmsbuild
merged 6 commits into
cms-sw:master
from
fwyzard:edm_Wraper_AllocateForOverwrite
Dec 11, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2368db5
Fix IOPool/Input test for modified DataFormats/Common
fwyzard 0c38ae5
Rename IOPool/Input test for consistency
fwyzard e274471
Let edm::Wrapper<T> use the constructor T{kUninitialized}
fwyzard 4c7f02a
Add tests for edm::Wrapper<T> using T{kUninitialized}
fwyzard 74c7d61
Let DeviceProduct<T> use the constructor T{kUninitialized}
fwyzard 4c8434c
Remove the default constructor from PortableCollection
fwyzard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef DataFormats_Common_interface_Uninitialized_h | ||
#define DataFormats_Common_interface_Uninitialized_h | ||
|
||
/* Uninitialized | ||
* | ||
* This is an empty struct used as a tag to signal that a constructor will leave an object (partially) uninitialised, | ||
* with the assumption that it will be overwritten before being used. | ||
* One expected use case is to replace the default constructor used when deserialising objects from a ROOT file. | ||
*/ | ||
|
||
namespace edm { | ||
|
||
struct Uninitialized {}; | ||
|
||
constexpr inline Uninitialized kUninitialized; | ||
|
||
} // namespace edm | ||
|
||
#endif // DataFormats_Common_interface_Uninitialized_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In principle we could have a case where
T
's default constructor is expensive, but it could provide a lightweightT(AllocateForOverwrite)
constructor. However, reversing the conditionalwould lead to constructor like
template <typename U> T(U)
to match to therequires
clause, and lead to compilation error (we have at least one case herecmssw/DataFormats/Common/interface/RefToBaseVector.h
Lines 41 to 42 in c5dc5f7
although we really should constrain the
REFV
type in any case).For our own types we can add the necessary constraints, but for third party classes it would be more difficult (doable with additional header in CMSSW code, but the setup would be somewhat brittle).
(we could leave this point to a time we have an expensive-to-default-construct data product type, but I felt the case would be useful to be mentioned)
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.
Yes, that's what I tried first, and I run into this kind of errors.
I'm happy to try and implement this inverted approach if you think it worthwhile.
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.
Maybe we leave it to a later time (usefulness in practice is somewhat unclear, and a straightforward approach wouldn't work well with third party classes).