C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Doubt about std 14.6.4.2

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Joaquín M López Muñoz
Guest





PostPosted: Tue Feb 14, 2006 1:06 am    Post subject: Doubt about std 14.6.4.2 Reply with quote



[I'm reposting here after some days without getting response
from comp.std.c++]

Consider the following snippet:

template<typename T>
static void foo(T){}

template<typename T>
void bar(T t)
{
foo(t);
}

int main()
{
bar(0);
}

This is illegal because of std 14.6.4.2, which states that

"For a function call that depends on a template parameter, if the
function name is an unqualified-id but not a template-id, the
candidate functions are found using the usual lookup rules
(basic.lookup.unqual, basic.lookup.koenig) except that:

[internal linkage function excluded from lookup]"

So far so good, I know the rationale behind exclusion of internal
linkage functions as a way to fight ODR violations. But consider
now the following, slightly different code:

template<typename T>
static void foo(){}

template<typename T>
void bar(T t)
{
foo<T>();
}

int main()
{
bar(0);
}

Seems like this must be also illegal for the same reasons as
before, and in fact Comeau Online says so, but a closer reading
of 14.6.4.2 reveals (emphasis mine):

"For a function call that depends on a template parameter, if the
function name is an unqualified-id ***but not a template-id***,..."

And, in the second snippet, foo is called thru the template-id
foo<T>!! So my questions are:

1. Am I right in thinking that 14.6.4.2 explicitly does not apply
to the second snippet where the unqualified call is a
template-id?
2. If so, what's the rationale? The same ODR problems occur here.

I guess I must be making some gross mistake here, but can't figure
it out.

Thank you,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.