Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hahnjo
Copy link
Member

@hahnjo hahnjo commented Nov 25, 2024

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 #14425, alternative to #14426

Copy link

github-actions bot commented Nov 25, 2024

Test Results

    18 files      18 suites   4d 3h 8m 23s ⏱️
 2 683 tests  2 683 ✅ 0 💤 0 ❌
46 458 runs  46 458 ✅ 0 💤 0 ❌

Results for commit 5ba7196.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@jblomer jblomer left a 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.

@hahnjo hahnjo force-pushed the callfunc-move branch 2 times, most recently from 6adfb63 to c123eea Compare November 26, 2024 10:29
@hahnjo hahnjo changed the title [core] Move non-copyable arguments in TClingCallFunc [core] Move arguments with deleted copy ctor in TClingCallFunc Nov 26, 2024
hahnjo and others added 4 commits November 26, 2024 14:05
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]>
Copy link
Member

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done, @hahnjo!

Copy link
Member

@dpiparo dpiparo left a 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();
Copy link
Member

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)

Copy link
Member Author

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

PyROOT calls into deleted copy-constructor in valid C++ scenarios
5 participants