Closed
Description
This program triggers a readability-implicit-bool-conversion clang-tidy warning:
#include <compare>
#include <list>
struct X
{
auto operator<=>(const X&) const = default;
bool m_b;
};
struct Y
{
auto operator<=>(const Y&) const = default;
std::list<X> m_xlist;
};
int main()
{
return 0;
}
The warning emitted is the following:
main.cpp:6:46: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
6 | auto operator<=>(const X&) const = default;
| ^
| static_cast<int>( )
The clang-tidy command used:
clang-tidy --checks=-*,readability-implicit-bool-conversion main.cpp
It is somewhat unfortunate that a generated function triggers such a warning. Of course one can add NOLINT() statements to all affected operators but that unnecessarily clutters the code and makes it harder to read.
Is it possible to alter the generated code and avoid this warning?