C++ - template-friend-operator überladen

Was ist falsch an meinem code?

template<int E, int F>
class Float
{
 friend Float<E, F> operator+ (const Float<E, F> &lhs, const Float<E, F> &rhs);
};

G++ nur hält Warnung:

float.h:7: warning: friend declaration ‘Float<E, F> operator+(const Float<E, F>&, const Float<E, F>&)’ declares a non-template function

float.h:7: warning: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) -Wno-non-template-friend disables this warning

Versuchte ich add <> after the function name here wie bereits in der Warnung, aber g++ gibt mir eine Fehlermeldung.

Ich kompiliert den code mit clang++, es war in Ordnung, keine Warnung an alle.

InformationsquelleAutor Zifei Tong | 2010-10-21
Schreibe einen Kommentar