Does ROOT not support STL’s UnaryPredicates, or am I doing something wrong? Thanks for your help!
root [0] TObjArray *arr = new TObjArray()
root [1] all_of(arr->begin(), arr->end(), [](TObject *obj) { return true; })
In module 'std' imported from input_line_1:1:
/usr/include/c++/9/bits/stl_algo.h:173:8: error: no matching function for call to '__iterator_category'
std::__iterator_category(__first));
^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/stl_algo.h:566:19: note: in instantiation of function template specialization 'std::__find_if_not<TIter, __gnu_cxx::__ops::_Iter_pred<(lambda at
ROOT_prompt_1:1:34)> >' requested here
return std::__find_if_not(__first, __last,
^
/usr/include/c++/9/bits/stl_algo.h:509:29: note: in instantiation of function template specialization 'std::find_if_not<TIter, (lambda at ROOT_prompt_1:1:34)>' requested here
{ return __last == std::find_if_not(__first, __last, __pred); }
^
ROOT_prompt_1:1:1: note: in instantiation of function template specialization 'std::all_of<TIter, (lambda at ROOT_prompt_1:1:34)>' requested here
all_of(arr->begin(), arr->end(), [](TObject *obj) { return true; })
^
/usr/include/c++/9/bits/stl_iterator_base_types.h:205:5: note: candidate template ignored: substitution failure [with _Iter = TIter]: no type named 'iterator_category' in
'std::iterator_traits<TIter>'
__iterator_category(const _Iter&)
^
It does work on some platforms and not others. It looks like the C++ std libraries you are using here as “additional/new” requirements for containers that we are not yet added (it seems to be that we are missing std::iterator_traits<TIter>)
If you can not switch to std::vector. You can use this work around for TObjArray:
Thanks, but I guess that will not check for the last element. There are definitely cleaner ways to test this but this is the first thing that came to my mind:
This sounds like a good candidate for a bug report at Issues · root-project/root · GitHub – however as Philippe mentioned we typically suggest to switch to STL containers if possible.