Re: Cannot find source of undefined identifier
From: Alf P. Steinbach (alfps_at_start.no)
Date: Wed, 31 Mar 2004 00:15:29 GMT
* Rob Williscroft <rtw@freenet.REMOVE.co.uk> schriebt:
> John Harrison wrote in
> >> The error is related to two-pahse name lookup, when a compiler
> >> supports this feature, identifiers in templates are bound
> >> when the template is first parsed, unless the name is dependant
> >> on a template paramiter. All of the 3 options above tell the
> >> compiler that 'is_goal' is a dependant name.
> > Foolishly I thought I'd try and work this out from the standard. Since
> > I've never thoroughly understood dependent name lookup I've probably
> > made a mistake but as far as I can tell is_goal is a dependent name.
> > 14.6.2 para 1 says that in expressions of the form
> > identifier ( expression-list )
> > identifier is a dependent name if and only if and of the expressions
> > in expression-list are type-dependent expressions. In this case then
> > only expression is current_state.
> > 184.108.40.206 para 3 says that current_state is type dependent name since
> > it was declared with a template parameter (STATE_T)
> > Therefore is_goal is a dependent name and should be looked up when the
> > template is instantiated not when it is parsed.
> Yep, I missed this.
> It appears that is_goal is a dependant name the problem is that its the
> wrong dependant name, when the template is parsed is_goal is identified
> as having the form of a non-member function taking a STATE_T as a
> From the standard 14.6.2:
> 3 In the definition of a class template or a member of a
> class template, if a base class of the class template
> depends on a template-parameter, the base class scope is not
> examined during unqualified name lookup either at the point
> of definition of the class template or member or during an
> instantiation of the class template or member.
> The relevent bit here is "... base class scope ... not examined ...
> during an instantiation ..."
> This is what requires use of this->base_member() or one of the
> other forms of qualifying the name.
Isn't it great with a language so complex that the practitioners
such as you and me (and I prefer to believe most others ;-)) can't
really predict what simple code will or will not do, or even why
our compilers spit out error messages at us?
I'm not sure how seriously I mean that.
But I do think that that will be a main factor in the downfall
of C++ and the ascendance of some replacement language, perhaps D,
perhaps some other as-yet-not-thought-of language.
-- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?