Changes between Version 3 and Version 4 of UserFriendlyTemplates

Show
Ignore:
Timestamp:
05/22/2007 04:41:34 PM (3 years ago)
Author:
robyn
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UserFriendlyTemplates

    v3 v4  
    1 === TBD === 
     1== Scenario when using Explicit Template Instantiation == 
     2 
     3(Compliments of Kian-Tat Lim) 
     4 
     5If explicit instantiation can be used (i.e. if all template parameters 
     6that will be used by the application are known ahead of time), then  
     7the following is the best method: 
     8 
     91) Put only the interface (template definition) in a .h file in a 
     10public include directory. 
     11 
     122) Put only the implementation in a .cc file in a private 
     13implementation or source directory.  This does not actually need to be 
     14compiled as such (although doing so does no harm, as it generates no 
     15code). 
     16 
     173) Add an additional .cc file that includes the .h file, the 
     18implementation .cc file from #2, and then explicitly instantiates the 
     19templates with the known parameters using "template class C<T>;" 
     20statements. 
     21 
     224) Compile everything, including application code, with 
     23-fno-implicit-templates. 
     24 
     255) Make sure the explicit instantiations resulting from compiling the 
     26.cc file in #3 are included in the appropriate library for application 
     27code to link against. 
     28 
     29This method isolates the application from changes to the template 
     30implementation, requiring only a relink against the new library rather 
     31than a recompile against the new template implementation code. 
     32 
     33 
     34 
     35== User Friendly Templates: A Scenario == 
    236Create scenario allowing framework developers to use templates but hiding 
    337template complexity from application developers.