Re: Templates question
Re: Templates question
- Subject: Re: Templates question
- From: John Mikros <email@hidden>
- Date: Fri, 23 Feb 2007 16:37:51 -0800
On Feb 23, 2007, at 4:27 PM, David Fang wrote:
To fix it, you still need a prefix. You have to add "this->" in
front of the function call. Since "this" depends on a template
parameter, the compiler can figure things out and knows the code is
acceptable.
Another solution instead of this-> is to place the following
declaration in class bar's definition:
using foo<T>::SetUpRenderStates;
Hi,
(Yes, people on this list will do their best to answer pure C++
questions! Fire away.)
By qualifying the call to your_method(), (with "this->" or
"base_class::"
you're telling the compiler to postpone the name lookup until template
*instantiation*. (Because a template-dependent base class can be
specialized with a completely different definition.) This is the idea
behind two-phase name lookup.
So, it isn't really an issue. Any modern C++ compiler should emit
this error. CodeWarrior is now defunct and doesn't qualify anymore.
I don't know about the latest MS compilers. The last time I
checked, VS.Net 2003 still had serious problems. I haven't checked
the 2005 editions. C++ really isn't their focus anymore.
Visual C++ 2005 does not give an error for that code.
Not familiar with VC, but you might look for various options to
enforce
standard conformance. For gcc, I recommend: -ansi -pedantic-errors.
Visual C++ doesn't seem to do two-phase lookup at all. In fact your
template can be complete garbage and the code will compile as long as
that template is never instantiated. I'm not defending VC++; I've
just had to deal with its differences from GCC, and this one's been a
big headache.
I think there's a "be more standards compliant" settting for VC++ but
it doesn't affect template instantiation.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden