Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > non-dependent name in template function

Thread Tools

non-dependent name in template function

George2 George2 is offline
Senior Member
Join Date: Feb 2008
Posts: 108
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,

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,
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use the template member function of a template in the memberfunction of another template class? Peng Yu C++ 3 10-26-2008 03:51 PM
Passing pointer to template function as argument to pointer to template function Vijai Kalyan C++ 4 11-08-2005 07:53 PM
parse error in gcc but success in, call a non_template class's template member function from a template class's member function! ken C++ 2 06-28-2005 06:57 AM
Template function as argument to another template function Jim West C++ 3 10-07-2004 07:21 PM
function non-template versus fully specialized function template Robert Allan Schwartz C++ 1 08-09-2004 03:41 PM