[Cs3] Remove_if clarification
Mikhail Nesterenko
mikhail at cs.kent.edu
Tue Oct 1 22:13:55 EDT 2019
Nicholas Potts wrote:
> however, I'm confused at what the difference is between
> these two lines of code. Can you explain the difference?
>
>
> auto it = std::remove_if(crate.begin(), crate.end(),[minAccept](Apples& a){ return a.weight < minAccept;});
> and
> auto it = std::remove_if(crate.begin(), crate.end(), [minAccept](Apples& a)->bool{return a.weight < minAccept;});
>
The ->bool specifies the return type of the lambda function. If it is
not explcitly provided, then the compiler determines it on the basis
of the type of the expression in the return statement. In this case
the two lines of code are the same since the implicit type of the
return statement is boolean.
Thanks,
--
Mikhail
More information about the cs3
mailing list