Hello Forum,
how do I iterate over, let’s say, a list of braches?
Example code:
// Prepare example
auto t = new TTree("t","t");
Int_t i; t->Branch("someBranch", &i);
auto lbr = t->GetListOfBranches();
// No:
find_if(begin(*lbr), end(*lbr),
[](auto o){ return o->GetName() == "someBranch"s; });
This does not work because there is no type named ‘iterator_category’ in ‘std::iterator_traits’. It seems only TIterCategory provides the traits.
So I came up with:
using ItT = remove_reference_t<decltype(*lbr)>;
find_if(TIterCategory<ItT>(lbr), TIterCategory<ItT>::End(),
[](auto o){ return o->GetName() == "someBranch"s; }))
Is there a simpler solution?
(tree->FindBranch
does not work for me, and also this problem can appear in other use cases)