Click here to Skip to main content
15,900,511 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generaltemplate function instantiation Pin
George_George5-Mar-08 22:22
George_George5-Mar-08 22:22 
Hello everyone,


For the following code from Bjarne's book, it is stated that template parameter T for function g will be instantised as int other than double. My question is why there are not two instantiations for both int and double version of template function g?

// section C.13.8.3 Point of Instantiatant Binding

template <class T> void f (T a) { g(a); }

void g(int);

void h()
{
	extern g (double);
	f (2);
}


Here is the related statement from Bjarne,

--------------------
Each use of a template for a given set of template arguments defines a point of instantiation.
That point is the nearest global or namespace scope enclosing its use,
just before the declaration that contains that use.
--------------------

Does it before g (double) is not global function or namespace scope enclosing its use? If yes, I do not know why g (double) is not a global function, since it is declared as extern and some other compile unit should expose it?


thanks in advance,
George
GeneralRe: template function instantiation Pin
CPallini5-Mar-08 22:35
mveCPallini5-Mar-08 22:35 
GeneralRe: template function instantiation Pin
George_George5-Mar-08 22:51
George_George5-Mar-08 22:51 
QuestionRe: template function instantiation Pin
CPallini5-Mar-08 22:53
mveCPallini5-Mar-08 22:53 
GeneralRe: template function instantiation Pin
George_George5-Mar-08 23:01
George_George5-Mar-08 23:01 
GeneralRe: template function instantiation Pin
CPallini5-Mar-08 23:23
mveCPallini5-Mar-08 23:23 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 0:12
George_George6-Mar-08 0:12 
GeneralRe: template function instantiation Pin
toxcct5-Mar-08 23:53
toxcct5-Mar-08 23:53 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 0:11
George_George6-Mar-08 0:11 
GeneralRe: template function instantiation Pin
Rajkumar R5-Mar-08 23:30
Rajkumar R5-Mar-08 23:30 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 0:07
George_George6-Mar-08 0:07 
GeneralRe: template function instantiation Pin
Rajkumar R6-Mar-08 0:52
Rajkumar R6-Mar-08 0:52 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 0:59
George_George6-Mar-08 0:59 
GeneralRe: template function instantiation Pin
Rajkumar R6-Mar-08 1:08
Rajkumar R6-Mar-08 1:08 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 1:21
George_George6-Mar-08 1:21 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 0:29
George_George6-Mar-08 0:29 
AnswerRe: template function instantiation [modified] Pin
Rajkumar R6-Mar-08 1:00
Rajkumar R6-Mar-08 1:00 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 1:56
George_George6-Mar-08 1:56 
GeneralRe: template function instantiation Pin
Rajkumar R6-Mar-08 2:04
Rajkumar R6-Mar-08 2:04 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 2:08
George_George6-Mar-08 2:08 
GeneralRe: template function instantiation Pin
Rajkumar R6-Mar-08 2:23
Rajkumar R6-Mar-08 2:23 
GeneralRe: template function instantiation Pin
George_George6-Mar-08 15:11
George_George6-Mar-08 15:11 
Generaliterator for deque Pin
George_George5-Mar-08 22:00
George_George5-Mar-08 22:00 
GeneralRe: iterator for deque Pin
Maximilien6-Mar-08 1:00
Maximilien6-Mar-08 1:00 
GeneralRe: iterator for deque Pin
George_George6-Mar-08 16:26
George_George6-Mar-08 16:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.