#include <map>
#include <string>
bool f1()
{
std::map<int, int> m;
auto it = m.find(0);
return (it != m.cend());
}
bool f2(int i)
{
return (i == 0); // no warning
}
int f3(const std::string& s)
{
return (s >= "0");
}
<source>:8:12: warning: redundant parentheses around expression [readability-redundant-parentheses]
8 | return (it != m.cend());
| ^ ~
<source>:18:12: warning: redundant parentheses around expression [readability-redundant-parentheses]
18 | return (s >= "0");
| ^ ~
https://godbolt.org/z/EvPde1hbq
I would have expected the warning in all three cases.
But I think having the parentheses around a comparison might actually have better readability (especially if there is multiple conditions) so I would like to have an option to control that.
https://godbolt.org/z/EvPde1hbq
I would have expected the warning in all three cases.
But I think having the parentheses around a comparison might actually have better readability (especially if there is multiple conditions) so I would like to have an option to control that.