[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

packaging template classses into libraries (static, dynamic

puzzlecracker

10/18/2008 6:22:00 PM

Is it possible to package a template implementation class into a
library and how it is done (say into a dll or a static one).

Since template expansion in c++ is static and takes place at compile
time (unlike csharp), I would like to find out how we can simulate
that?


Thank
3 Answers

killerfox

10/19/2008 1:44:00 AM

0

On Oct 18, 11:21 am, puzzlecracker <ironsel2...@gmail.com> wrote:
> Is it possible to package a template implementation class into a
> library and how it is done (say into a dll or a static one).
>
> Since template expansion in c++ is static and takes place at compile
> time (unlike csharp), I would like to find out how  we can simulate
> that?
>
> Thank

I don't think that is possible at all, since libraries are already
compiled, and just need to be linked, whereas templates need to be
seen by the compiler to generate the code.

One thing I can think of is wrapping all your template headers into a
precompiled header, and include this in your other projects, but other
than that I don't think its possible.

-Kf-

John

10/19/2008 10:06:00 PM

0

http://www.informit.com/guides/content.aspx?g=cplusplus&...
about exported template classes.

"killerfox" <killerfox512@gmail.com> wrote in message
news:126da3ea-beba-4f44-9e1b-fb8b302f132b@l64g2000hse.googlegroups.com...
On Oct 18, 11:21 am, puzzlecracker <ironsel2...@gmail.com> wrote:
> Is it possible to package a template implementation class into a
> library and how it is done (say into a dll or a static one).
>
> Since template expansion in c++ is static and takes place at compile
> time (unlike csharp), I would like to find out how we can simulate
> that?
>
> Thank

I don't think that is possible at all, since libraries are already
compiled, and just need to be linked, whereas templates need to be
seen by the compiler to generate the code.

One thing I can think of is wrapping all your template headers into a
precompiled header, and include this in your other projects, but other
than that I don't think its possible.

-Kf-


Paavo Helde

10/20/2008 4:45:00 AM

0

puzzlecracker <ironsel2000@gmail.com> kirjutas:

> Is it possible to package a template implementation class into a
> library and how it is done (say into a dll or a static one).
>
> Since template expansion in c++ is static and takes place at compile
> time (unlike csharp), I would like to find out how we can simulate
> that?

See http://www.parashift.com/c++-faq-lite/templates.html...

Paavo