1// RUN: %check_clang_tidy -std=c++20 %s readability-implicit-bool-conversion %t
2
3namespace std {
4struct strong_ordering {
5 int n;
6 constexpr operator int() const { return n; }
7 static const strong_ordering equal, greater, less;
8};
9constexpr strong_ordering strong_ordering::equal = {.n: 0};
10constexpr strong_ordering strong_ordering::greater = {.n: 1};
11constexpr strong_ordering strong_ordering::less = {.n: -1};
12} // namespace std
13
14namespace PR93409 {
15 struct X
16 {
17 auto operator<=>(const X&) const = default;
18 bool m_b;
19 };
20
21 struct Y
22 {
23 auto operator<=>(const Y&) const = default;
24 X m_x;
25 };
26
27 bool compare(const Y& y1, const Y& y2)
28 {
29 return y1 == y2 || y1 < y2 || y1 > y2;
30 }
31}
32

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-cxx20.cpp