TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  POR#026

This rule is Obsolete
Synopsis:Only one #include directive should be needed when using a template
Language:C++
Severity Level:9
Category:Portability


Description:

There is no standard for how template source code is organized and how much of a template to instantiate for a particular set of arguments.

A function template is used when it is called, or its address is taken. A class template is used when instances of the class template are used to declare objects.

Some compilers require that the implementation either be part of the header file or be included by the header file.

Other compilers use file-name conventions to determine where to find the implementation. The implementation should be in a file with the same name as the header file, but with the implementation file extension substituted for the header file extension.

This is a potential portability problem when writing code using templates. We recommend to always put the implementation in a separate file, a template definition file. By using conditional compilation to control if this file is included or not, the same source code can be used with different compilers.



Literature References:
ISC++ Rec 15.16