Q: Hiding template implementation

Kirk McDonald kirklin.mcdonald at gmail.com
Tue Jun 12 11:38:18 PDT 2007


Myron Alexander wrote:
> Hello.
> 
> How do you hide the template implementation when compiling a library?
> 
> Regards,
> 
> Myron.

You can't. Templates don't compile to anything on their own. Object code 
for them is only generated when the template is instantiated. In order 
to instantiate a template, the code using the template needs full access 
to the template's source.

D's templates are very much like C++'s templates in this respect. The 
following is somewhat relevant:
http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12
(Though note it is about C++ and not D, so many of the specifics are 
different.)

-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org


More information about the Digitalmars-d-learn mailing list