compilo questo codice con GCC (4.2.1 di Apple di costruire 5664)ambiguo definizione di operatore() con l'ereditarietà multipla
#include <cstddef>
using std::size_t;
template <char I> struct index { };
struct a
{
void operator()(size_t const &) { }
};
struct b
{
template <char I>
void operator()(index<I> const &) { }
};
struct c: public a, public b { };
int main (int argc, char const *argv[])
{
c vc;
vc(1);
return 0;
}
e mi danno il seguente errore:
main.cpp: In function ‘int main(int, const char**)’:
main.cpp:22: error: request for member ‘operator()’ is ambiguous
main.cpp:14: error: candidates are: template<char I> void b::operator()(const index<I>&)
main.cpp:9: error: void a::operator()(const size_t&)
I don' t comprendere il motivo per cui questo codice è ambiguo; i due metodi hanno diverse firme.
Sono sorpreso che Clang può compilare il codice, mentre GCC si lamenta. – peoro