mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
777b182edd
This allowed me to standardize the sourcetar and sf/* scripts: the base directory (containing ./git) is now empty, except for maintenance scripts, while the source files and build scripts of the annotations are stored in a subdirectory of their own.
38 lines
1.7 KiB
Text
38 lines
1.7 KiB
Text
Different from function templates, template parameters of template classes may
|
|
be given default argument
|
|
hi(class template: default arguments) values.
|
|
This holds true for both template type- and template non-type
|
|
parameters. If default template arguments were defined and if a class template
|
|
object is instantiated without specifying arguments for its template
|
|
parameters then the template parameter's defaults are used.
|
|
|
|
When defining defaults keep in mind that they should be suitable for the
|
|
majority of instantiations of the class. E.g., for the class template
|
|
tt(CirQue) the template's type parameter list could have been altered
|
|
by specifying tt(int) as its default type:
|
|
verb(
|
|
template <typename Data = int>
|
|
)
|
|
|
|
Even though default arguments can be specified, the compiler must still be
|
|
informed that object definitions refer to templates. When instantiating class
|
|
template objects using default template arguments the type specifications may
|
|
be omitted but the angle brackets must be retained. Assuming a default
|
|
type for the tt(CirQue) class, an object of that class may be defined
|
|
as:
|
|
verb(
|
|
CirQue<> intCirQue(10);
|
|
)
|
|
|
|
Default template arguments cannot be specified when defining template
|
|
members. So, the definition of, e.g., the tt(push_back) member must always
|
|
begin with the same tt(template) specification:
|
|
verb(
|
|
template <typename Data>
|
|
)
|
|
|
|
When a class template uses multiple template parameters, all may be given
|
|
default values. Like default function arguments, once a default value is used
|
|
all remaining template parameters must also use their default values. A
|
|
template type specification list may not start with a comma, nor may it
|
|
contain multiple consecutive commas.
|