~ubuntu-branches/ubuntu/trusty/c++-annotations/trusty

« back to all changes in this revision

Viewing changes to yo/classtemplates/externtemplate.yo

  • Committer: Package Import Robot
  • Author(s): Frank B. Brokken
  • Date: 2011-09-12 16:08:05 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: package-import@ubuntu.com-20110912160805-r9dq68beojgzuien
Tags: 9.0.2-1
New upstream release (editorial changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    extern template class std::vector<int>;
18
18
        )
19
19
    Having declared the class template it can be used in its translation
20
 
unit. E.g., the following function will properly compile:
 
20
unit. E.g., the following function  properly compiles:
21
21
        verbinclude(examples/extern.cc)
22
22
    But be careful:
23
23
    itemization(
35
35
constructors, conversion operators, constructors called during promotions, to
36
36
name a few): all are assumed by the compiler to have been instantiated
37
37
elsewhere;
38
 
    it() The above source file will em(compile) but the compiler must find the
39
 
instantiations before its linker can produce a final program. To accomplish
40
 
this one or more sourcefiles may be constructed in which all required
41
 
instantiations are made available.
 
38
    it() Although the above source file em(compile), the em(instantiations) of
 
39
the templates must be available before the linker can build the final
 
40
program. To accomplish this one or more sourcefiles may be constructed in
 
41
which all required instantiations are made available.
42
42
 
43
43
    In a stand-alone program one might postpone defining the required members
44
44
and wait for the linker to complain about unresolved external
49
49
define an emi(instantiation source) em(file) in which all facilities that
50
50
are used by the program are actually instantiated in a function that is never
51
51
called by the program. By adding this i(instantiation function) to the source
52
 
file containing tt(main) we can be sure that all required members will be
 
52
file containing tt(main) we can be sure that all required members are
53
53
instantiated as well. Here is an example of how this can be done:
54
54
        verbinclude(examples/extern2.cc)
55
55
    )