繁体   English   中英

将类C ++指针的向量发送到python

[英]Send vector of class C++ pointers to python

我在将std向量传递给python时遇到问题。

   std::vector<TMVA::Interval*> parameterRanges;
   parameterRanges.push_back(new TMVA::Interval(-10,10)); 
   parameterRanges.push_back(new TMVA::Interval(0.1,10)); 
   parameterRanges.push_back(new TMVA::Interval(0,2000));

而且我必须在python中做到这一点。 不幸的是我不能更改Interval C ++类。 我可以在python中使用std.vector,但只能使用std.vector('double')或int,但不能使用对象类型。

你有什么主意吗?

当您使用TMVA时,我假设您也具有ROOT。 在pyroot中还有一个ROOT std :: vector包装器。 它的用法如下:

import ROOT
VectorOfIntervalPointer = ROOT.std.vector('TMVA::Interval*')
# this is only a constructor, not an instance!

instance = VectorOfIntervalPointer()
from ROOT import TMVA.Interval
instance.push_back(TMVA.Interval(-10,10))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM