この正しい動作であるかどうかを理解するのに役立つ人がいますか?char *とchar [N]のあいまいなエラー
この例で考えてみましょう:GCCで
#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;
}
は、予想通り、それはうまくコンパイルし、 '0' を出力4.7.3。
しかし、Visual Studioコンパイラでは、ambiguous error (C2593)
が報告されます。
この状況では、誰が正しいのですか。standard
はそれについて何と言いますか?
ありがとうございます。
曖昧ですと思います。 – Shoe