Re: name binding from one template to another
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Tue, 11 Mar 2008 21:48:39 -0400
"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:89AAF8B5-2E13-484A-A1FD-B8730F09860F@xxxxxxxxxxxxx
But for a two-step name-lookup compiler, I am curious, how did
compiler binds another referred template from one template in the
first name lookup step, before instantiation?
The compiler can look up primary template itself in the first phase -
basically, just verify that it exists (in fact, a forward declaration is
sufficient). But any members of that template (whether member types,
data members or member functions) are dependent names and are looked up
in second phase.
Since template symbol is not finalized until it is instantised. But
during the first step of compiler look-up, the compiler only sees the
definition of template, how could it bind (generate binary code to
link to some symbol)
I'm not sure what you are talking about. Name lookup doesn't involve
generating any binary code, let alone linking. It simply establishes
which previously declared entity a name refers to.
For example, in the following code, during the 1st step of name-lookup
before function func is instantised, how did compiler work internally
to bind to vector<T> (T is not ready at this time, so vector<T> is
not instantised)?
Or, I am wrong that compiler will do nothing to bind the referred
template, like vector<T> in the sample?
What do you mean by "bind" here? If you mean "instantiate", then no, the
compiler won't instantiate vector until it has to instantiate func.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: name binding from one template to another
- From: George
- Re: name binding from one template to another
- Prev by Date: Re: functions
- Next by Date: Re: MSDN template sample
- Previous by thread: doxygen
- Next by thread: Re: name binding from one template to another
- Index(es):
Relevant Pages
|