template <typename T>
class rp {
};
template <template <typename> class P>
struct b {
template <class, template <typename> class FriendP>
friend void f(b<FriendP> from);
};
template <class, template <typename> class P>
void f(b<P> from) {
}
int main() {
b<rp> v;
f<int>(v);
return 0;
}
Clang 3.3 (SVN) compila bene, mentre GCC 4.8 rifiuta:GCC rivendica una funzione amico per essere sovraccaricato, chiamata ambigua, clang compila
main.cpp: In function 'int main()':
main.cpp:17:10: error: call of overloaded 'f(b<rp>&)' is ambiguous
f<int>(v);
^
main.cpp:17:10: note: candidates are:
main.cpp:12:6: note: void f(b<P>) [with <template-parameter-1-1> = int; P = rp]
void f(b<P> from) {
^
main.cpp:8:17: note: void f(b<FriendP>) [with <template-parameter-2-1> = int; FriendP = rp; P = rp]
friend void f(b<FriendP> from);
^
Mi chiedo perché GCC sostiene f
da sovraccarico . Quindi penso che sia un bug GCC.
Quale compilatore ha ragione?
Quale 'f()' richiama clang? –
Poiché solo la definizione 'f' outside' b' ha un corpo e non ci sono errori di linker, che 'f' deve essere invocato. In effetti c'è solo una 'f'. – hpohl
Direi che si tratta di un bug GCC. –