Reputation: 871
In boost::unordered_map, the template is declared like this:
template <class K, class T, class H, class P, class A>
class unordered_map
{
and at the bottom of the template, there's a method declared like this:
friend bool operator==<K,T,H,P,A>(
unordered_map const&, unordered_map const&);
Could anyone please tell me why <K, T, H, P, A> is needed here?
Thanks!
Upvotes: 0
Views: 48
Reputation: 137404
As written, the line declares as a friend a particular specialization of the operator==
function template declared previously as
template <class K, class T, class H, class P, class A>
bool operator==(unordered_map<K, T, H, P, A> const&,
unordered_map<K, T, H, P, A> const&);
If you remove the <K,T,H,P,A>
-
friend bool operator==(unordered_map const&, unordered_map const&);
Then it would instead befriend a non-template function operator==
, separate and distinct from the function template, which would be incorrect.
(The relevant standardese is found in §14.5.4 [temp.friends]/p1.)
Upvotes: 2