vendredi 31 mars 2017

Invoking ranges::for_each with lambda and global function

The following code works as expected:

void foo(auto const &){}

auto const rng{ranges::view::all(v)};
ranges::for_each(rng, [](auto const & r){
    foo(r);
});

But the following:

void foo(auto const &){}

auto const rng{ranges::view::all(v)};
ranges::for_each(rng, &foo);

Gives the compilation error:

template argument deduction/substitution failed:
couldn't deduce template parameter 'F'

I took a look at the source but to be honest I couldn't understand the problem.

Aucun commentaire:

Enregistrer un commentaire