• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Passing templated friend function of a class to other function as parameter results in error

Resolved: Passing templated friend function of a class to other function as parameter results in error

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

The following code demonstrates the problem.
Here is the here link to compiler explorer
It probably has to do something with argument dependent lookup, but i cannot really get it.

Answer:

The problem is that the friend declaration for foo 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.
Working demo

Method 2


Here we provide a forward declarations for the function template foo and then define it later outside the class.
Working demo

If you have better answer, please add a comment about this, thank you!

c++ templates
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why is NGINX’s $request_uri empty?

24/03/2023

Resolved: How to convert Java bytecode to Webassembly using CheerpJ compiler

24/03/2023

Resolved: Is pandas groupby() function always produce a DataFrame with the same order respect to the column we group by?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.