Przeciążenie operatora znajomego << dla klasy szablonu

Próbuję przeciążyć operatora << jako znajomego do klasy szablonu Pair, ale ciągle otrzymuję ostrzeżenie o kompilatorze

friend declaration std::ostream& operator<<(ostream& out, Pair<T,U>& v) declares a non template function

dla tego kodu:

friend ostream& operator<<(ostream&, Pair<T,U>&);

daje drugie ostrzeżenie jako zalecenie

if this is not what you intended, make sure the function template has already been declared and add <> after the function name here

Oto definicja funkcji

template <class T, class U>
ostream& operator<<(ostream& out, Pair<T,U>& v)
{
    out << v.val1 << " " << v.val2;
}

a oto cała klasa.

template <class T, class U>
class Pair{
public:
    Pair(T v1, U v2) : val1(v1), val2(v2){}
    ~Pair(){}
    Pair& operator=(const Pair&);
    friend ostream& operator<<(ostream&, Pair<T,U>&);

private:
    T val1;
    U val2;
};

Nie byłam pewna, co wyciągnąć z ostrzeżenia o rekomendacji, poza tym może muszę umieścić gdzieś w deklaracji przyjaciela. Czy ktoś zna właściwą składnię? Dzięki.

questionAnswers(3)

yourAnswerToTheQuestion