By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,855 Members | 865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,855 IT Pros & Developers. It's quick & easy.

templates being exported

P: n/a
Hi Everyone,

I was looking at the link,

http://www.comeaucomputing.com/4.0/d...an/export.html

and it looks like the basic purpose of exporting templates is make
sure that they are visible in other compilation units for the compiler
to perform instantiation... is this because template instantiation is
something done at compile time by the compiler?

had template instantiation been done at linking time, would extern
keyword have worked? I understand that it really doesn't make sense
for the linker to do, i'm just trying to understand the reason why
export keyword came into picture...

Thanks in advance!!!
Jan 13 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jan 13, 12:52 pm, Rahul <sam_...@yahoo.co.inwrote:
I was looking at the link,
http://www.comeaucomputing.com/4.0/d...an/export.html
and it looks like the basic purpose of exporting templates is make
sure that they are visible in other compilation units for the compiler
to perform instantiation...
No. The main purpose of exporting templates is to prevent their
being parsed in the context of the user. The implementation of
an exported template will not be affected by symbols (nor
macros) that the user might introduce. A second purpose is to
reduce the time of recompilations if the template implementation
is modified.
is this because template instantiation is something done at
compile time by the compiler?
When the template instantiation occurs is not specified; I've
used compilers which do it at compile time, and compilers which
do it at link time.
had template instantiation been done at linking time, would
extern keyword have worked? I understand that it really
doesn't make sense for the linker to do, i'm just trying to
understand the reason why export keyword came into picture...
The reason is basically because some people wanted to be able to
use templates in large applications; they didn't want the
template implementation to be subject to the aleas of whatever
else a user might have defined in the file using it. Basically,
they wanted templates to "work", just like any other class or
function "works".

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jan 13 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.