I have a function getTotal:
int getTotal( const HitMap& hitMap, bool( *accept)(int chan) )
where the second argument is a bool function specifying which members of the container hitMap should be added to the total.
I'm trying to call it with a lambda. This works:
auto boxresult =
getTotal(piHits, [](int pmt)->bool
{ return (pmt/100) == 1;} );
but this doesn't:
int sector = 100;
auto boxresult =
getTotal(piHits, [sector](int pmt)->bool
{ return (pmt/sector) == 1;} );
I get the error
cannot convert ‘main(int, char**)::<lambda(int)>’ to ‘bool (*)(int)’
for argument ‘2’ to ‘int getTotal(const HitMap&, bool (*)(int))’
from my compiler (GCC 4.6.3). I tried [§or]
and [=sector]
but it didn't make any difference.
What am I doing wrong?