Weird ROOT bug?

When I run the code:

auto start = std::next(std::begin(someVec), from);
auto stop =  std::prev(std::end(someVec), (ROWS-1) - to);

return std::count_if(start, stop, [column, target](auto & row)
    { return row[column] > target; });

In ROOT, I get the following errors:

ROOT_prompt_6:1:55: error: 'auto' not allowed in lambda parameter
auto x =  std::count_if(start, stop, [column, target](auto & row)
                                                      ^~~~
In module 'std' imported from input_line_1:1:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_algo.h:4656:6: error: no matching function for call to object of type '(lambda at ROOT_prompt_6:1:38)'
        if (__pred(*__first))
            ^~~~~~
ROOT_prompt_6:1:16: note: in instantiation of function template specialization 'std::count_if<__gnu_cxx::__normal_iterator<std::vector<double, std::allocator<double> > *, std::vector<std::vector<double, std::allocator<double>
      >, std::allocator<std::vector<double, std::allocator<double> > > > >, (lambda at ROOT_prompt_6:1:38)>' requested here
auto x =  std::count_if(start, stop, [column, target](auto & row)
               ^
ROOT_prompt_6:1:38: note: candidate function not viable: no known conversion from 'std::vector<double, std::allocator<double> >' to 'int &' for 1st argument
auto x =  std::count_if(start, stop, [column, target](auto & row)

This compiles just fine elsewhere:

Is there a way to adjust my code so as to use it in ROOT?


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,
auto lambda parameters are a C++14 feature. You need a ROOT version compiled for (at least) C++14 to use the feature in interpreted code (you can check e.g. by inspecting the -std argument that root-config --cflags prints).

Cheers,
Enrico

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.