javascripty wrote: |
---|
How might this be fixed to get the lambda to work? |
You need to actually invoke the lambda.
Something like this should work (passing
rating as argument to the lambda).
|
if ([](const std::string& rating) { return rating.find_first_not_of("*") != rating.npos; }(rating))
|
javascripty wrote: |
---|
Trying to evaluate if the string rating contains characters other than '*' |
You don't need to use a lambda to do that.
Something like this should work (and is less verbose).
|
if (rating.find_first_not_of("*") != rating.npos)
|
Enoizat wrote: |
---|
why gcc warns me about the address of that lambda. To what I can see, it seems it wants me to be fully aware of the fact that a reference address (in this case, I guess of the parameter) would never be NULL. Very kind of it, but why in this case is so important? |
You get the same type of error if you put a function inside an if condition without calling it.
This code is useless because the if statement is checking if the function pointer is not null, which is always true, because it points to
some_function. If you write such code it is most likely a mistake.
This is probably what the author intended.
Same problem with the lambda. The lambda was implicitly converted to a function pointer which is never null.