Question:
The following code demonstrates the problem.It probably has to do something with argument dependent lookup, but i cannot really get it.
Answer:
The problem is that the friend declaration forfoo
that you’ve provided is for a non-template function but while calling bar you’re trying to use foo
as a template.There are 2 ways to solve this:
Method 1
Here we provide a separate parameter clause for
foo
.Method 2
Here we provide a forward declarations for the function template
foo
and then define it later outside the class.If you have better answer, please add a comment about this, thank you!