过去9个小时,我一直在打着我的头部。
我只与M3处理器(ARM)一道安装了一个新的MacBookPro,并安装了所有的指挥系统工具,包括clang
和
clang++>
is mistaking a bian/code> declaration within a group and its definition out the category as two separate functions, debeit with same signature.
我已把我有问题的法典尽可能减少,以揭露汇编错误的原因。 我相信,这意味着<条码>clang<>/代码>是错的,因为我手写的是C++,但从未这样做——该法典还汇编了对我其他Macs和Loplin的罚款。
我删除并重列了所有指挥系统工具。 Sam。
这里是光带法:
#include <iostream>
namespace gml {
template <typename T>
concept Numeric = requires (T value) {
T{};
// lots of stuff...
};
template <Numeric T>
class tensor {
// lots more stuff...
public:
tensor() = default; // constructs an empty tensor
template <Numeric U, Numeric V>
friend bool operator==(const tensor<U>&, const tensor<V>&);
};
template <Numeric U, Numeric V>
bool operator==(const tensor<U>& t1, const tensor<V>& t2) {
return true;
}
}
int main() {
gml::tensor<long double> t;
gml::tensor<long double> t3;
std::cout << std::boolalpha << "t == t3: " << (t == t3) << std::endl;
return 0;
}
......并在此是我从以上所述汇编错误:
test.cpp:26:54: error: use of overloaded operator == is ambiguous (with operand types gml::tensor<long double> and gml::tensor<long double> )
std::cout << std::boolalpha << "t == t3: " << (t == t3) << std::endl;
~ ^ ~~
test.cpp:15:21: note: candidate function [with U = long double, V = long double]
friend bool operator==(const tensor<U>&, const tensor<V>&);
^
test.cpp:18:10: note: candidate function [with U = long double, V = long double]
bool operator==(const tensor<U> &t1, const tensor<V> &t2) {
^
1 error generated.
如果有人能让我对此有所了解,我将非常感激。
P.S.,我用<代码>clang++-std=c++20 测试.cpp-o test和运行clang++-version
印刷:
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin