命名空间“std”在 macOS clang 上没有成员“lexicographyal_compare_ Three_way”

问题描述 投票:0回答:1

我一直在尝试从 cppreference 编译这个示例

#include <algorithm> #include <cctype> #include <compare> #include <iomanip> #include <iostream> #include <string_view> #include <utility> using namespace std::literals; void show_result(std::string_view s1, std::string_view s2, std::strong_ordering o) { std::cout << std::quoted(s1) << " is "; std::is_lt(o) ? std::cout << "less than ": std::is_gt(o) ? std::cout << "greater than ": std::cout << "equal to "; std::cout << std::quoted(s2) << '\n'; } std::strong_ordering cmp_icase(unsigned char x, unsigned char y) { return std::toupper(x) <=> std::toupper(y); }; int main() { for (const auto& [s1, s2] : { std::pair{"one"sv, "ONE"sv}, {"two"sv, "four"sv}, {"three"sv, "two"sv} }) { const auto res = std::lexicographical_compare_three_way( s1.cbegin(), s1.cend(), s2.cbegin(), s2.cend(), cmp_icase); show_result(s1, s2, res); } }
我在 godbolt 上运行良好,但它似乎无法在我的 macOS M1 上编译

我一直使用这些命令来编译:

g++ -std=c++20 test.cpp # Apple Clang 15.0.0 clang++ -std=c++20 test.cpp # Homebrew clang version 16.0.6
这是错误:

test.cpp:31:31: error: no member named 'lexicographical_compare_three_way' in namespace 'std'; did you mean 'lexicographical_compare'? const auto res = std::lexicographical_compare_three_way( ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lexicographical_compare /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/lexicographical_compare.h:42:1: note: 'lexicographical_compare' declared here lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, ^
    
c++ clang c++20 clang++
1个回答
0
投票
我将其发布在 llvm-project 的 github 页面上,他们说这只能从 libc++ 17 获得

实施提交

© www.soinside.com 2019 - 2024. All rights reserved.