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
|
In this section the basic syntactical constructions when declaring templates
are summarized. When em(defining) templates, the terminating
semicolon should be replaced by a function body. However, not every template
declaration may be converted into a template definition. If a definition may
be provided it is explicitly mentioned.
itemization(
it() A plain template declaration (a definition is possible):
verb(
template <typename Type1, typename Type2>
void function(Type1 const &t1, Type2 const &t2);
)
it() A template instantiation declaration (no definition):
verb(
template
void function<int, double>(int const &t1, double const &t2);
)
it() A template using explicit types (no definition):
verb(
void (*fp)(double, double) = function<double, double>;
void (*fp)(int, int) = function<int, int>;
)
it() A template specialization (a definition is possible):
verb(
template <>
void function<char *, char *>(char *const &t1, char *const &t2);
)
it() A template declaration declaring friend template functions within
hi(template class: friend template function)
template classes (covered in section ref(TEMPFRIENDS)):
verb(
friend void function<Type1, Type2>(parameters);
)
)
|