Czy to jest błąd kompilatora?Operator w zakresie przestrzeni nazw ukrywający inny w zakresie globalnym
template <typename T>
T& operator++(T& t)
{
return t;
}
namespace asdf {
enum Foo { };
enum Bar { };
Foo& operator++(Foo& foo);
void fun()
{
Bar bar;
++bar;
}
} // end namespace asdf
int main()
{
return 0;
}
Komunikat o błędzie GCC 4.7 jest:
error: no match for 'operator++' in '++bar'
note: candidate is:
note: asdf::Foo& asdf::operator++(asdf::Foo&)
note: no known conversion for argument 1 from 'asdf::Bar' to 'asdf::Foo&'
To kompiluje jeśli skomentuj linię:
Foo& operator++(Foo& foo);
[Tak jest] (http://liveworkspace.org/code/2vreOi$0) .... –
Nie sądzę. VC++ generuje to samo. – SChepurin
@KarthikT: Nie jestem pewien, w jaki sposób połączony kod obsługuje "argument o błędzie". –