TFormula usage in ROOT6 with methods that take std::vector?

Hi,

I am wondering how I can get a TFormula/TTreeFormula to work in ROOT6 using a function that takes an std::vector as an argument. For example, if I have a class that has a function like this:

double myMethod( const std::vector<int>& myVec ) const;
And I have objects of that class type in my ROOT file. It seems that this is not possible on the ROOT6 command line:

myTTree->Draw("MyClassObj.myMethod({0,3,2})");
I get this kind of error:

Error in <TTreeFormula::DefinedVariable>: Unknown method:myMethod({0,1}) in MyClassObj Error in <TTreeFormula::Compile>: Bad numerical expression : "MyClassObj.myMethod({0,1})" Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {MyClassObj.myMethod({0,1}),}
I thought that ROOT6 Cling should understand C++11. But maybe not in this context?

I have tried to implement in my class other method signatures, e.g. something like this:

double myMethod2( std::vector<int>&& myVec ) const;
or

double myMethod2( std::initializer_list<int> myVec ) const;
But both gave me the same error.

Thanks already,

Karsten

Hi Karsten,

unfortunately TTreeFormula does not take advantage of cling yet. It however is on the todo list for this year:
https://sft.its.cern.ch/jira/browse/ROOT-5083

Once that is there, the power of modern C++ will be yours. :slight_smile:

Cheers,
Benedikt