C++ Template Compilation Model

Inclusion Model: Complete source code for Template functions will be available in the header files. This is because, the template functions are compiled at the user end for a type specified by the user. This need source code for the template function, hence all the template functions are always included in the header file itself. This is the only portable way available. Most STL libraries are available in header files. Alternately, the functions will be defined in a source file and the source file will be included in the headerfile ( achieves partial seperation of interface from implementation), but still the code in these source file will be compiled only at the user end. Major problem, not for all, is that source is exposed.

Export Model or Seperation Model: To avoid this problem of templates having to be present in the headerfiles, the C++ standard introduced a template compilation model with a keyword "export". But looks like, this has not been successfully implemented so far. Add "export" as qualifier to either the template declaration or definition to use the feature. However, most of the available versions of compilers still need full source code to be shipped to the users, and seems there are still a few other issues.

One issue with using export is illustrated at http://www.glenmccl.com/ansi_017.htm

Export Restrictions, C/C++ Users Journal, 20(9), September 2002 (
http://www.gotw.ca/publications/mill23.htmhttp://www.gotw.ca/publications/mill23.htm
)

Comments

Popular posts from this blog

Newsworthy News in Red October : Dow Jones & Tax Dodgers

USCIS Selects Final H1B Petitions by Random Selection - Almost a 50% chance for each Application

Wanna-be an Entrepreneur? Get Started