I’m seeing a strange problem when trying to interpret and the use a C++ class from python.
[code]>>>>>> ROOT.gInterpreter.LoadText(“struct B {B(int i) : a(i) {}; int a;};struct C : public B { using B::B; int b=3;};”)
True
ROOT.C(4)
Traceback (most recent call last):
File “”, line 1, in
TypeError: none of the 3 overloaded methods succeeded. Full details:
C::C() =>
takes at most 0 arguments (1 given)
C::C(const C&) =>
could not convert argument 1
C::C(C&&) =>
could not convert argument 1 (this method can not (yet) be called)
[/code]
This just works in standard root.
Now if I use the C ctor in the text to be interpreted it works :
[code]>>>>>> ROOT.gInterpreter.LoadText(“struct B {B(int i) : a(i) {}; int a;};struct C : public B { using B::B; int b=3;};void f(){C c(4);}”)
True
ROOT.C(4)
<ROOT.C object at 0x2fe3bf0>
[/code]
Am I doing something wrong ?
Btw are the differences between gInterpreter->LoadText() and gInterpreter->ProcessLine() ?
From some my tests it seems the code from the first runs much faster : is it actually compiled while the other is only interpreted ?
‘using’ relations were not made available through the reflection layer, so PyROOT is blind to them. In the past, I’ve made a few common 'using’s explicitly available (see AddUsingToClass() in Utility.cxx). I’m not aware of current changes/upgrades in ROOT/meta, but then I’m not following those either.
Thanks for your answer. There’s still something I don’t understand : the exact same line orks with 6.04.
[code]>>>>>> ROOT.gROOT.GetVersion()
‘6.04/02’
ROOT.gInterpreter.LoadText(“struct B {B(int i) : a(i) {}; int a;};struct C : public B { using B::B; int b=3;};”)
True
ROOT.C(4)
<ROOT.C object at 0x290f7e0>
c=ROOT.C(4)
c.a
4
[/code]
The error I reported was obtained with 6.08.
Also could you point me to this AddUsingToolClass() : the search box in the reference guide is unable to find it.
if it worked before and not later, then it must be on ROOT/meta’s TCling side. I’d file a bug report then. (Checking ‘git log’ only shows removal of ‘tab’ and trailing white spaces as edits, so it can’t be on the PyROOT side.) As for ‘AddUsingToolClass’ … the method I wrote about is ‘AddUsingToClass’ and it is not part of the public interface.