Declaring template function friends involves some incredibly unintuitive syntax, even for C++! What is the rationale behind the choice of syntax for the extra <>
Quoting this page:
The non-template function is called because a non-template function takes precedence in overload resolution.
So my guess the friend void bar<>(Foo
is intuitive because you want to make sure it's the template function you are calling and not an overload for Foo
. There would otherwise no way for the compiler to notice if the templated or the non-templated function is the class'es friend.
Why the <>
syntax is used and not the template
syntax is not clear to me.