Template Separate Compilation and Specialization

Template Separate Compilation and Specialization - Template...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Template Separate Compilation and Specialization Jonathan Schilling, jls@sco.com In C++ Newsletter #017 the new template separate compilation model was described. Since its introduction the ANSI/ISO standards committee has been dealing with sorting out the loose ends from this addition to the language. Take the following case, for instance: file1.h: template<class T> class A { }; template<class T> void f(T); file1.C: #include "file1.h" export template<class T> void f(T) { A<T> a; } These files introduce a template class, and a template function whose definition depends upon the template class. The keyword "export" says that the template function definition doesn't have to be included into translation units that call it; rather it can be separately compiled. file2.C: #include "file1.h" template<> class A<int> { }; // line 2 void g() ( f(1); } // line 3 Line 2 of this file declares a specialization (see C++ Newsletter #012) of the class template for type int, and then line 3 instantiates the function template for type int,
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/27/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 2

Template Separate Compilation and Specialization - Template...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online