An-Algorithm-Library icon indicating copy to clipboard operation
An-Algorithm-Library copied to clipboard

const may not be correct afterall.

Open Sebanisu opened this issue 4 years ago • 0 comments

https://github.com/codereport/An-Algorithm-Library/blob/1a94a025ad0a187cc0fd39bb6bcbc9a5791338b2/src/aal/algorithm.hpp#L9

If the user is using a mutable lambda. Then they can't use the algorithm. So might need to remove const from these.

We might want to test a mutable lambda to see if it's working as expected. like [x=0] and ++x to make sure all the functions are correctly incrementing the value.

Though it should be fine I did some testing with compiler explorer. So I understand. The last function in the call will get the one that will increment because they are all pass by value.

https://github.com/codereport/An-Algorithm-Library/blob/1a94a025ad0a187cc0fd39bb6bcbc9a5791338b2/src/aal/algorithm.hpp#L19 Here we could forward the value to find. It might be better since any_of isn't actually calling the lambda.

Sebanisu avatar Jun 21 '21 16:06 Sebanisu