-
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
Open
hahnjo
wants to merge
4
commits into
root-project:master
Choose a base branch
from
hahnjo:callfunc-move
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+292
−2
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e1c70e9
[core] Move arguments with deleted copy ctor in TClingCallFunc
hahnjo b468886
[core] Optimize IsCopyConstructorDeleted
hahnjo eea1069
[core] Add test with non-copyable arguments from Python
hahnjo 5ba7196
[ntuple] Test writing and reading from Python
hahnjo 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
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,34 @@ | ||
import unittest | ||
|
||
import ROOT | ||
|
||
class TClingCallFuncTest(unittest.TestCase): | ||
"""Tests related to TClingCallFunc usage from Python""" | ||
|
||
def test_GH_14425(self): | ||
"""Can call a function with non-copyable argument.""" | ||
|
||
ROOT.gInterpreter.Declare(r""" | ||
struct GH_14425 { | ||
int fMember; | ||
GH_14425(int m = 1) : fMember(m) {} | ||
GH_14425(const GH_14425&) = delete; | ||
GH_14425(GH_14425&&) = default; | ||
}; | ||
int GH_14425_f(GH_14425 p = GH_14425()) { return p.fMember; } | ||
int GH_14425_g(GH_14425 p) { return p.fMember; } | ||
struct GH_14425_Default { | ||
int fMember; | ||
GH_14425_Default(GH_14425 p = GH_14425()) : fMember(p.fMember) {} | ||
}; | ||
struct GH_14425_Required { | ||
int fMember; | ||
GH_14425_Required(GH_14425 p) : fMember(p.fMember) {} | ||
}; | ||
""") | ||
self.assertEqual(ROOT.GH_14425_f(), 1) | ||
self.assertEqual(ROOT.GH_14425_f(ROOT.GH_14425(2)), 2) | ||
self.assertEqual(ROOT.GH_14425_g(ROOT.GH_14425(3)), 3) | ||
self.assertEqual(ROOT.GH_14425_Default().fMember, 1) | ||
self.assertEqual(ROOT.GH_14425_Default(ROOT.GH_14425(2)).fMember, 2) | ||
self.assertEqual(ROOT.GH_14425_Required(ROOT.GH_14425(3)).fMember, 3) |
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,22 @@ | ||
import unittest | ||
|
||
import ROOT | ||
|
||
RNTupleModel = ROOT.Experimental.RNTupleModel | ||
RNTupleReader = ROOT.Experimental.RNTupleReader | ||
RNTupleWriter = ROOT.Experimental.RNTupleWriter | ||
|
||
class RNTupleBasics(unittest.TestCase): | ||
"""Basic tests of using RNTuple from Python""" | ||
|
||
def test_write_read(self): | ||
"""Can write and read a basic RNTuple.""" | ||
|
||
model = RNTupleModel.Create() | ||
model.MakeField["int"]("f") | ||
writer = RNTupleWriter.Recreate(model, "ntpl", "test_ntuple_py_write_read.root") | ||
writer.Fill() | ||
del writer | ||
|
||
reader = RNTupleReader.Open("ntpl", "test_ntuple_py_write_read.root") | ||
self.assertEqual(reader.GetNEntries(), 1) |
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.
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 constructorpublic
...