name binding from one template to another

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


For non-template function/class, compiler knows the symbol is there and bind to a definite symbol. It is straight forward to understand.

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?

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) (before a referred template is instantised, the real code is not generated)?

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?

Code:
template <class T> void func (T a)
{
    vector<T> vc;
    vc.push_back (a);
    // ...
}


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top