-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.cxxTemplates
46 lines (37 loc) · 1.49 KB
/
README.cxxTemplates
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
The C++ templates supplied with EPICS base are in
"$(EPICS)/base/src/cxxTemplates".
In Stroustrups's "The C++ Programming Language" Appendix A: r.14.9
(ANSI/ISO resolutions) a mechanism is described for the explicit
instantiation of template member functions (that are not inline).
At this time some compilers do not support this mechanism (and use
a template database snd/or smart linker instead). Other compilers
(such as g++) provide only limited support for other forms of
instantiation (g++ does not yet provide a template database or
a smart linker for templates).
Since there is no defacto standard mechanism for instatiating
templates at this time we are defining the preprocessor flag
EXPL_TEMPL in the build system when the compiler supports
explicit instantiation and the compiler does not support
automatic instantiation via a smart linker and/or template
database (currently this is only g++).
EPICS codes that use templates may need to include a code block
as follow that instantiates the template only once into each
program.
#include <classXYZ.h>
#include <templXXX.h>
//
// if the compiler supports explicit instantiation of
// template member functions
//
#if defined(EXPL_TEMPL)
//
// From Stroustrups's "The C++ Programming Language"
// Appendix A: r.14.9
//
// This explicitly instantiates the template class's member
// functions into "templInst.o"
//
template class templXXX <classXYZ>;
#endif
Jeff Hill 3-6-97