Template classes in deal.II
can be grouped into three categories, depending on the number of probable different instantiations. These three groups are discussed in the following.
template <int dim> class Function;
Here, we have a small number of instantiations (dim = 1,2,3
) known at the time of design of the library. Therefore, member functions of this class are defined in a .cc
file in the source directory and we instantiate the template for these known values explicitly in the source file.
From an application viewpoint, all you actually get to see then is the declaration of the template. Actual instantiations of member functions happens inside the library and is done when you compile the library, not when you compile your application code.
For these classes, adding instantiations for new parameters involves changing the library. However, this is rarely needed, of course, unless you are not content with computing only in 1d, 2d, or 3d.
dim
, the available instances are for dim=1,2,3
, if there is no other information.
There are other cases of classes (not depending on the spatial dimension) for which only a certain, small number of template arguments is supported and explicit instantiations are provided in the library. In particular, this includes all the linear algebra classes that are templatized on the type of the scalar underlying stored values: we only support double
, float
, and in some cases long double
, std::complex<double>
, std::complex<float>
, and std::complex<long double>
.
Typical examples for this would be some of the linear algebra classes that take a vector type as template argument. They would be instantiated within the library for Vector<double>
, Vector<float>
, BlockVector<double>
, and BlockVector<float>
, for example. However, they may also be used with other vector types as long as they satisfy certain interfaces, including vector types that are not part of the library but possibly defined in an application program. In such a case, applications can instantiate these templates by hand as described in the next section.
XXXX
, defined in the header file xxxx.h
, instantiated with the template parameter Lager
. Then, your file should contain the lines // Include class template declaration #include <xxxx.h> // Include member definitions #include <xxxx.templates.h> ... template class XXXX<Lager>;
Template Instantiations: some (<p1>a,b,c<p2>)