Ambiguous error with char* and char[N]

Viewed 504

Can someone help me to understand is this correct behavior or not.

Consider this example:

#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;
}

With gcc 4.7.3 it compiles just fine and outputs '0' as expected.

But with Visual Studio compiler it reports an ambiguous error (C2593).

Who is right in this situation and what does standard say about it?

Thank you.

2 Answers
Related