non-dependent name in template function

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


I am confused about what Bjarne means below, and I quoted the section name, his words and his sample.

My question is, what did he mean "A call that by coincidence has an argument that matches an actual template parameter type is not dependent"?

I think the compile error is because, g (1) function call is not dependent on template parameter, and it should be resolved in the definition phase (not instantiation phase) of template function f. But in definition phase of f, what g is (the symbol g) can not be resolved. So comes the compile error.

Is my analysis correct? What did Bjarne mean?

(section C.13.8.1 Dependent Names)

--------------------
A call that by coincidence has an argument that matches an actual template parameter type is not dependent. For example,
--------------------

Code:
template <class T> T f (T a)
{
	return g (1); // error: no g() in scope and g(1) doesn't depent on T
}

int g (int);

int z = f (2);


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top