Details
-
Bug
-
Status: Closed (View Workflow)
-
High
-
Resolution: Fixed
-
6.20/06
-
- macOS 10.15.5
- Python 3.7.6 (Homebrew)
- Apple clang 11.0.3
Description
Conversion from std::shared_ptr<TGraph> to std::shared_ptr<const TGraph> works in C++.
#include <memory>
|
#include "TGraph.h" |
|
void foo(std::shared_ptr<const TGraph> gra) { |
gra->Dump();
|
}
|
|
void test() { |
auto graph = std::make_shared<TGraph>();
|
foo(graph);
|
}
|
$ root
|
root [0] .x test.C+ |
==> Dumping object at: 0x00007ffa37c785c8, name=, class=TGraph |
|
fMaxSize 0 !Current dimension of arrays fX and fY |
(snip)
|
But it doesn't in PyROOT.
import ROOT |
|
ROOT.gInterpreter.Declare('void foo(shared_ptr<const TGraph> gra) {gra->Dump();}') |
ROOT.gROOT.ProcessLine('auto graph = std::make_shared<TGraph>();') |
ROOT.foo(ROOT.graph)
|
In [1]: %run test.py --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~/test.py in <module> |
3 ROOT.gInterpreter.Declare('void foo(shared_ptr<const TGraph> gra) {gra->Dump();}') |
4 ROOT.gROOT.ProcessLine('auto graph = std::make_shared<TGraph>();') |
----> 5 ROOT.foo(ROOT.graph) |
6 |
7 |
TypeError: void ::foo(shared_ptr<const TGraph> gra) => |
could not convert argument 1 |
I remember it was working a while ago, when Wim advised me to use gInterpreter.ProcessLine in this thread.
https://root-forum.cern.ch/t/root-std-shared-ptr-in-python/35021