-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[core] Move arguments with deleted copy ctor in TClingCallFunc #17030
base: master
Are you sure you want to change the base?
Conversation
Test Results 18 files 18 suites 4d 3h 8m 23s ⏱️ Results for commit 5ba7196. ♻️ This comment has been updated with latest results. |
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.
LGTM for the RNTuple part.
6adfb63
to
c123eea
Compare
If a type is passed by value but cannot be copy-constructed, instead move the argument. This is important to make std::unique_ptr interfaces work from Python code. Note that there are corner cases where checking for a deleted copy constructor is not sufficient; for example the STL always declares a copy constructor for std::vector<std::unique_ptr<T>> which fails to instantiate if T is only moveable. Closes root-project#14425 Co-authored-by: Vincenzo Eduardo Padulano <[email protected]>
Co-authored-by: Vassil Vassilev <[email protected]>
c123eea
to
5ba7196
Compare
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.
Nicely done, @hahnjo!
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.
Very nice improvement and complete test coverage: thanks!
|
||
for (auto *Ctor : RD->ctors()) { | ||
if (Ctor->isCopyConstructor()) { | ||
return Ctor->isDeleted(); |
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.
Should we also return true is the constructor is private or protected? (Since it has essentially the same effect)
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.
I would argue that no because it may be unexpected for the user that TClingCallFunc
moves its objects when they "forget" to make their copy constructor public
...
If a type is passed by value but cannot be copy-constructed, instead move the argument. This is important to make
std::unique_ptr
interfaces work from Python code. Note that there are corner cases where checking for a deleted copy constructor is not sufficient; for example the STL always declares a copy constructor forstd::vector<std::unique_ptr<T>>
which fails to instantiate if
T
is only moveable.Closes #14425, alternative to #14426