|
-
November 28th, 2002, 11:16 AM
#1
Templates increase code size, a way around this ?
I like templates and even if I didn't I would still have to use them since ATL is mostly based on them.
But the problem I face (I think, please correct me if I'm wrong) is that whenever a template class is instantiated with a different parameter, all of its functions are "written out in full" by the compiler. This is usually fine, but the problem comes from the functions in the class which don't depend on the template parameters. They should not need to get get duplicated and unneccessarily increase the code size.
My concrete problem is that I have defined a templated "boiler-plate" windowed ActiveX object derived from about 15 ATL templates and a few of my own classes that does the basic window management, forwards the messages appropriately and does some other funky stuff.
The only reason I have to make this class templated is that otherwise I can't derive it from the basic ATL templates, don't have access to the required ATL variables (like m_bWindowOnly e.g.), can't call base functions (in only a very few of my functions) and can't expect ATL to call my overridden virtual functions.
Most of the overridden virtual functions don't require any template arguments, so having them in the templated class unfortunately duplicates them in the compiler-generated code and increases the size :/
What could I do ?
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|