Defined Terms
- class template(类模板)
-
A class definition that can be used to define a set of type-specific classes. Class templates are defined using the template keyword followed by a comma-separated list of one or more parameters enclosed in < and > brackets.
可以用来定义一组特定类型的类的类定义。类模板用 template 关键字后接用尖括号(<>)括住、以逗号分隔的一个或多个形参的列表来定义。
- export keyword(导出关键字)
-
Keyword used to indicate that the compiler must remember the location of the associated template definition. Used by compilers that support the separate-compilation model of template instantiation. The export keyword ordinarily goes with a function definition; a class is normally declared as exported in the associated class implementation file. A template may be defined with the export keyword only once in a program.
用来指出编译器必须记住相关模板定义位置的关键字,支持模板实例化的分别编译模型的编译器使用它。export 关键字一般与函数定义一起出现,类通常在相关类实现文件中声明为 export。在一个程序中,一个模板只能用 export 关键字定义一次。
- function template(函数模板)
-
A definition for a function that can be used for a variety of types. A function template is defined using the template keyword followed by a comma-separated list of template one or more parameters enclosed in < and > brackets.
可用于不同类型的函数的定义。函数模板用 template 关键字后接用尖括号(<>)括住、以逗号分隔的一个或多个形参的列表来定义。
- generic handle class(泛型句柄类)
-
A class that holds and manages a pointer to another class. A generic handle takes a single type parameter and allocates and manages a pointer to an object of that type. The handle class defines the necessary copy control members. It also defines the dereference (*) and arrow (->) member access operators to provide access to the underlying object. A generic handle requires no knowledge of the type it manages.
保存和管理指向其他类的指针的类。泛型句柄接受单个类型形参,并且分配和管理指向该类型对象的指针。句柄类定义了必要的复制控制成员,它还定义了解引用操作符(*)和箭头成员访问操作符(->)。泛型句不需要了解它管理的类型。
- inclusion compilation model(包含编译模型)
-
Mechanism used by compilers to find template definitions that relies on template definitions being included in each file that uses the template. Typically, template definitions are stored in a header, and that header must be included in any file that uses the template.
编译器用来寻找模板定义的机制,它依赖于模板定义被包含在每个使用模板的文件中。一般而言,模板定义存储在一个头文件中,使用模板的任意文件必须包含该文件。
- instantiation(实例化)
-
Compiler process whereby the actual template argument(s) are used to generate a specific instance of the template in which the parameter(s) are replaced by the corresponding argument(s). Functions are instantiated automatically based on the arguments used in a call. Template arguments must be provided explicitly whenever a class template is used.
用实际模板实参产生模板特定实例的编译器过程,在该实例中,用对应实参代替形参。函数基于调用中使用的实参自动实例化,使用类模板时必须显式提供模板实参。
- member template(成员模板)
-
A member of a class or class template that is a function template. A member template may not be virtual.
类或类模板的是函数模板的成员。成员模板不能为虚。
- nontype parameter(非类型形参)
-
A template parameter that represents a value. When a function template is instantiated, each nontype parameter is bound to a constant expression as indicated by the arguments used in the call. When a class template is instantiated, each nontype parameter is bound to a constant expression as indicated by the arguments used in the class instantiation.
表示值的模板形参。在实例化函数模板的时候,将每个非类型形参绑定到一个常量表达式,该常量表达式作为调用中使用的实参给出。在实例化类模板的时候,将每个非类型形参绑定到一个常量表达式,该常量表达式作为类实例化中使用的实参给出。
- partial specialization(部分特化)
-
A version of a class template in which some some but not all of the template parameters are specified.
类模板的一个版本,其中指定了某些但非全部的模板形参。
- separate compilation model(分别编译模型)
-
Mechanism used by compilers to find template definitions that allows template definitions and declarations to be stored in independent files. Template declarations are placed in a header, and the definition appears only once in the program, typically in a source file. The compiler implements whatever programming environment support is necessary to find that source file and instantiate the versions of the template used by the program.
编译器用来查找模板定义的机制,它允许将模板定义和声明存储在独立的文件中。模板声明放在一个头文件中,而定义只在程序中出现一次,一般在源文件中,无论什么编程环境所支持的编译器都必须找到该源文件,并实例化程序所使用的模板版本。
- template argument(模板实参)
-
Type or value specified when using a template type, such as when defining an object or naming a type in a cast.
在使用模板类型(如定义对象或强制类型转换中指定类型)的时候,指定的类型或值。
- template argument deduction(模板实参推断)
-
Process by which the compiler determines which function template to instantiate. The compiler examines the types of the arguments that were specified using a template parameter. It automatically instantiates a version of the function with those types or values bound to the template parameters.
编译器用来确定实例化哪个函数模板的过程。编译器检查用模板形参指定的实参的类型,它用绑定到模板形参的类型或值自动实例化函数的一个版本。
- template parameter(模板形参)
-
A name specifed in the template parameter list that may be used inside the definition of a template. Template parameters can be type or non-type parameters. To use a class template, actual arguments must be specified for each template parameter. The compiler uses those types or values to instantiate a version of the class in which uses of the parameter(s) are replaced by the actual argument(s). When a function template is used, the compiler deduces the template arguments from the arguments in the call and instantiates a specific function using the deduced template arguments.
在模板形参表中指定的、可以在模板定义内部使用的名字。模板形参可以是类型形参或非类型形参。要使用模板,必须为每个模板形参指定实参,编译器使用这些类型或值来实例化类的一个版本,其中形参的使用以实参代替。当使用函数模板的时候,编译器从函数调用中的实参推断模板实参,并使用推断得到的模板实参实例化特定函数。
- template parameter list(模板形参表)
-
List of type or nontype parameters (separated by commas) to be used in the definition or declaration of a template.
在模板定义或声明中使用的类型形参或非类型形参(以逗号分隔)的列表。
- template specialization(模板特化)
-
Redefinition of a class template or a member of a class template in which the template parameters are specified. A template specialization may not appear until after the class that it specializes has been defined. A template specialization must appear before any use of the template for the specialized arguments is used.
类模板或类模板的成员的重定义,其中指定了模板形参。在定义了被特化的模板之前,不能出现该模板的特化。在使用任意实参特化的模板之前,必须先出现模板特化。
- type parameter(类型形参)
-
Name used in a template parameter list to represent a type. When the template is instantiated, each type parameter is bound to an actual type. In a function template, the types are inferred from the argument types or are explicitly specified in the call. Type arguments must be specified for a class template when the class is used.
模板形参表中使用的表示类型的名字。当实例化模板的时候,将每个类型形参绑定到实际类型。在函数模板中,从实参类型中推断类型或者在调用中显式指定类型。类模板的类型实参必须在使用类的时候指定。
|