For Programmers: Free Programming Magazines  


Home > Archive > VC Language > June 2005 > Seperating template classes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Seperating template classes
WithPit

2005-06-11, 8:58 am

I have some C++ code that is using template classes and typdefs which use
this template classes.

What i understand about template classes, is that when you are compiling the
code, the compiler looks which different types are used for the template
classes and generate internally for each type a new class for the specific
type.

I heard some rumours about giving some options to the cl.exe to get the new
classes stored as separate files. Does somebody knows how to get this done?
The reason i want to do this, is that doxygen documentation generator has
some problems with template classes.
Arnaud Debaene

2005-06-11, 8:58 am

WithPit wrote:
> I have some C++ code that is using template classes and typdefs which
> use this template classes.
>
> What i understand about template classes, is that when you are
> compiling the code, the compiler looks which different types are used
> for the template classes and generate internally for each type a new
> class for the specific type.

Yes, that's about it : there is a separate binary code generation for each
used instanciation of the template class.

> I heard some rumours about giving some options to the cl.exe to get
> the new classes stored as separate files. Does somebody knows how to
> get this done?

This is the "export" keyword, that is specified in the norm to allow to
write template class implementation in a separate source file, and not in
the header file as we do today.
It is however only supported by a few compilers (those using the EDG
front-end : Comeau, etc...). What is more, some knowledgeable people have
advocated that is may not be as usefull as it seems to be at first glance :
it is a tricky issue, still bad understood and heavily debated in the C++
community, and itmay lead to deep modifications of the C/C++ 2 phases
compilation model.
I don't believe we may expect VC to implement it in the near future, and it
defintely not supported yet.

> The reason i want to do this, is that doxygen
> documentation generator has some problems with template classes.

export won't change anything about Doxygen. Have you got the last Doxygen
version? I dont't have any problem with it concerning templates.

Arnaud
MVP - VC


WithPit

2005-06-11, 8:58 am

Thanx you for your answer. I use doxygen for a managed wrapping process. I
was trying to get some library managed but have some problems with this
situation when a typedef is used with a template class

typedef TemplateArray<Vec3,Array::Vec3ArrayType,3,GL_FLOAT> Vec3Array;

template<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>
class TemplateIndexArray : public IndexArray, public std::vector<T>
{
....
}

In the doxygen output the typedef is not found for this situation. So i
though maybe this can be written to seperated files. But otherwise i should
create them by hand or with some small tool.

"Arnaud Debaene" wrote:

> WithPit wrote:
> Yes, that's about it : there is a separate binary code generation for each
> used instanciation of the template class.
>
> This is the "export" keyword, that is specified in the norm to allow to
> write template class implementation in a separate source file, and not in
> the header file as we do today.
> It is however only supported by a few compilers (those using the EDG
> front-end : Comeau, etc...). What is more, some knowledgeable people have
> advocated that is may not be as usefull as it seems to be at first glance :
> it is a tricky issue, still bad understood and heavily debated in the C++
> community, and itmay lead to deep modifications of the C/C++ 2 phases
> compilation model.
> I don't believe we may expect VC to implement it in the near future, and it
> defintely not supported yet.
>
> export won't change anything about Doxygen. Have you got the last Doxygen
> version? I dont't have any problem with it concerning templates.
>
> Arnaud
> MVP - VC
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com