谁能帮助我了解这种行为是否正确。
考虑这个例子:
#include <iostream>
using namespace std;
template <typename T>
struct test {
};
template <typename T>
bool operator==(const test<T>& obj, const T* arr) {
return true;
}
template <typename T, size_t TN>
bool operator==(const test<T>& obj, const T (&arr)[TN]) {
return false;
}
int main() {
cout << ( test<char>() == "string" ) <<endl;
return 0;
}
使用 gcc 4.7.3,它编译得很好,并按预期输出“0”。
但是对于 Visual Studio 编译器,它会报告一个不明确的错误 (C2593)
。
在这种情况下谁是对的?标准
对此有何看法?
谢谢。
最佳答案
关于c++ - char* 和 char[N] 的模糊错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20747180/