In bf(C++) templates
    hi(template: when instantiated)
 are instantiated when the address of a function template or class template
object is taken or when a function template or class template is used. As
described in section ref(DECLCLASSTEMP) it is possible to (forward) declare a
class template to allow the definition of a pointer or reference to
that template class or to allow it being used as a return type.

In other situations templates are instantiated when they are being used.  If
this happens many times (i.e., in many different source files) then this may
slow down the compilation process considerably. Fortunately, bf(C++) allows
programmers to em(prevent) templates
    hi(template: preventing instantiation)
 from being instantiated, using the 
ti(extern template) syntax. Example:
        verb(
    extern template class std::vector<int>;
        )
    Having declared the class template it can be used in its translation
unit. E.g., the following function  properly compiles:
        verbinclude(-a examples/extern.cc)
    But be careful:
    itemization(
    it() The declaration by itself does em(not) make the class definition
available. The tt(vector) header file em(still) needs to be included to make
the features of the class vector known to the compiler. But due to the
tt(extern template) declaration none of the used members will be instantiated
for the current compilation unit;
    it() The compiler em(assumes) (as it always does) that what is declared
has been implemented elsewhere. In this case the compiler encounters an
em(implicit declaration): the features of the vector class that are actually
used by the above program are not individually declared but they are declared
as a group, using the ti(extern template) declaration. This not only holds
true for explicitly used members but hidden members (copy constructors, move
constructors, conversion operators, constructors called during promotions, to
name a few): all are assumed by the compiler to have been instantiated
elsewhere;
    it() Although the above source file em(compiles), the em(instantiations)
of the templates must be available before the linker can build the final
program. To accomplish this one or more source files may be constructed in
which all required instantiations are made available.

    In a stand-alone program one might postpone defining the required members
and wait for the linker to complain about unresolved external
references. These may then be used to create a series of instantiation
declarations which are then linked to the program to satisfy the linker. Not
a very simple task, though, as the declarations must strictly match the way
the members are declared in the class interface. An easier approach is to
define an emi(instantiation source) em(file) in which all facilities that
are used by the program are actually instantiated in a function that is never
called by the program. By adding this i(instantiation function) to the source
file containing tt(main) we can be sure that all required members are
instantiated as well. Here is an example of how this can be done:
        verbinclude(-a examples/extern2.cc)

    it() Last, but certainly not least: a fully matching
        i(instantiation declaration) of a class template (e.g., for
tt(std::vector<int>)) looks like this:
            verb(
template class std::vector<int>;
            )
    Adding this to a source file, however, will instantiate the em(full
class), i.e., all its members are now instantiated. This may not what you
want, as it might needlessly inflate your final executable.
    it() On the other hand, if it is known that the required template members
have already been instantiated elsewhere, then an emi(extern template)
declaration can be used to prevent member instantiations in the current
compilation unit, which may speed up compilation. E.g.,
        verb(
        // the compiler assumes that required members of
        // vector<int> have already been instantiated elsewhere
extern template class std::vector<int>;

int main()
{
    std::vector<int> vi(5);     // constructor and operator[]
    ++vi[0];                    // are NOT instantiated
}
            )
    )
