#pragma do_not_instantiate (C++ only)

Category

Template control

Purpose

Prevents the specified template declaration from being instantiated.

You can use this pragma to suppress the implicit instantiation of a template for which a definition is supplied.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-#--pragma--do_not_instantiate--template_class_name----------><

Parameters

template_class_name
The name of the template class that should not be instantiated.

Usage

Note: C++0x is a new version of the C++ programming language standard. This is a draft standard and has not been officially adopted in its entirety. The implementation of C++0x is based on IBM's interpretation of the draft C++0x standard and is subject to change at any time without notice. IBM makes no attempt to maintain compatibility with earlier releases and therefore the C++0x language extension should not be relied on as a stable programming interface.

If you are handling template instantiations manually (that is, -qnotempinc and -qnotemplateregistry are specified), and the specified template instantiation already exists in another compilation unit, using #pragma do_not_instantiate ensures that you do not get multiple symbol definitions during the link step.

C++0x #pragma do_not_instantiate on a class template specialization is treated as an explicit instantiation declaration of the template. This pragma provides a subset of the functionality of the explicit instantiation declarations feature, which is introduced by the C++0x standard. It is provided for compatibility purposes only and is not recommended. New applications should use explicit instantiation declarations instead.

You can also use the -qtmplinst option to suppress implicit instantiation of template declarations for multiple compilation units. See -qtmplinst (C++ only).

Examples

The following shows the usage of the pragma:
#pragma do_not_instantiate Stack < int >

Related information