我下载了你说的那个,奇怪的是不起作用。
我用Qt5.15.14的时候,C++20的代码报错;同一个工程,我切换成Qt6.5的时候,就不报错了,正常运行;
#include <iostream>
#include <compare>
using namespace std ;
int main() {
int a = 10;
int b = 20;
auto result = a <=> b;
if (result == std::strong_ordering::less) {
std::cout << "a is less than b" << std::endl;
} else if (result == std::strong_ordering::greater) {
std::cout << "a is greater than b" << std::endl;
} else {
std::cout << "a is equal to b" << std::endl;
}
return 0;
}