C++ 未为std::string定义三向比较运算符(<;=>;)

C++ 未为std::string定义三向比较运算符(<;=>;),c++,cmake,c++20,default-comparisons,C++,Cmake,C++20,Default Comparisons,我正试图在我的程序中使用c++20新的三向运算符()功能,但似乎这个运算符不是为字符串定义的,就像这个程序一样 #include <compare> #include <string> using namespace std; int main() { string a = "a"; string b = "b"; auto x = (a <=> b); return 0; }

我正试图在我的程序中使用c++20新的三向运算符()功能,但似乎这个运算符不是为字符串定义的,就像这个程序一样

#include <compare>
#include <string>

using namespace std;

int main()
{

    string a = "a";
    string b = "b";
    auto x = (a <=> b);

    return 0;
}


我在visualstudio中使用MSVC进行编译

比Cmake更重要,您使用的是什么编译器?我不认为任何主要的编译器已经完全实现了C++20,如果GCC或其他东西还没有
std::string
,我也不会感到惊讶。特别是对于MSVC,“将太空船
添加到库中”被列为“VS 2019 16.7中的部分”,并带有一个似乎没有更多细节的脚注。听起来只是编译器还没有一个完整的C++20实现。VS 2016 16.10预览版3声称std库C++20已经完成。但不适用于生产代码。VS 2019 16.10已发布以供通用。“我们的编译器和STL现在为最新可用的C++20标准提供了完整的功能!16.10附带了一些备受期待的功能:日历、时区和时间。”
Error   C2676   binary '<=>': 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
cmake_minimum_required (VERSION 3.8)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)