Ray's playground

 

C++ templates chapter 10(Instantiation)

On-Demand Instantiation
This on-demand instantiation feature sets C++ templates apart from similar facilities in other compiled languages. It is sometimes also called implicit or automatic instantiation.

Lazy Instantiation

When a class template is implicitly instantiated, each declaration of its members is instantiated as well, but the corresponding definitions are not. There are a few exceptions to this. First, if the class template contains an anonymous union, the members of that union's definition are also instantiated. [3] The other exception occurs with virtual member functions. Their definitions may or may not be instantiated as a result of instantiating a class template. Many implementations will, in fact, instantiate the definition because the internal structure that enables the virtual call mechanism requires the virtual functions actually to exist as linkable entities.

The C++ Instantiation Model
Two-Phase Lookup
Points of Instantiation
The Inclusion and Separation Models
Greedy Instantiation
Queried Instantiation
Iterated Instantiation

posted on 2009-10-15 20:53  Ray Z  阅读(387)  评论(0编辑  收藏  举报

导航