RAD Studio
ContentsIndex
PreviousUpNext
Compiler Template Switches

This section contains Compiler Template Switch topics.

Name 
Description 
The -Jg family of switches control how instances of templates are generated by the compiler. Every template instance encountered by the compiler will be affected by the value of the switch at the point where the first occurrence of that particular instance is seen by the compiler.
For template functions the switch applies to the function instances; for template classes, it applies to all member functions and static data members of the template class. In all cases, this switch applies only to compiler-generated template instances and never to user-defined instances. It can be used, however, to tell the compiler which... more 
The C++ compiler generates the following methods for template instances:
  • Those methods which were actually used
  • Virtual methods of an instance
  • All methods of explicitly instantiated classes
The advantage of this behavior is that it results in significantly smaller object files, libraries and executable files, depending on how heavily you use templates.
Optionally, you can use the ‘-Ja’ switch to generate all methods.
You can also force all of the out-of-line methods of a template instance to be generated by using the explicit template instantiation syntax defined in the ISO/ANSI C++ Standard. The syntax is:
template class classname<template... more 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!