![](/img/trans.png)
[英]Apple Clang: can't compile call to std::erase for vector with custom allocator
[英]Apple's clang can't use <=> with std::tuple
以下代码在 GCC 和godbolt上编译得很好,但在我的 MacBook 上,在 Xcode 14 中它死了:
#include <iostream>
#include <compare>
#include <tuple>
using std::cout; using std::tuple; using std::endl;
int main() {
tuple<float, float> tuplee = {1.0,2.0};
tuple<float, float> tuploo = {3.0,4.0};
cout << (tuplee < tuploo) << endl;
auto res = (tuplee <=> tuploo);
cout << (res < 0) << endl;
return 0;
}
错误是:
二进制表达式的无效操作数('std::tuple<float, float>' 和 'std::tuple<float, float>')
它指向元组上的<=>
。 你认为这是 Apple 的 clang 中的错误,还是我遗漏了什么?
我的 MacBook 上的命令行:
% clang++ --version
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
% clang++ -std=c++2b main.cpp
main.cpp:11:21: error: invalid operands to binary expression ('tuple<float, float>' and 'tuple<float, float>')
cout << (tuplee <=> tuploo) << endl;
~~~~~~ ^ ~~~~~~
1 error generated.
我认为这是一个错误。 该错误已在 llvm 中修复( 相关更改)。 但是通过检查 Macos SDK 中的元组头,可以发现苹果没有为元组实现 <=> 。
该错误还影响 Macos 的 arm64 变体。 我的 Mac 上的 Clang 版本:
➜ test clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
附言。 自制 llvm@14 编译正常。 只是不要使用 apple clang
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.