当要将某个模板类型参数用作基类列表中的模板参数时,必须显式地将该模板类型参数添加到模板类名中。
You must explicitly add the template type parameters to the template class name when using it as a template parameter in a base class list.
你可以可以为变量指明数据类型,输入参数,来自函数的返回值,用户自定义函数以及模板。
You are also able to specify data types for variables, input parameters, return values from functions, user-defined functions and templates.
比如,模板可能需要用接收的参数和已知类型的值进行值比较。
For example, the template might perform a value comparison on an incoming parameter against a value of a known type.
利用2.0中对数据类型的敏感特性,传入参数可能需要转换成特定的类型以便在模板中使用。
With the heightened awareness of data types in 2.0, incoming parameters might need to be cast into a particular type in order to be useful in the template.
图6.创建一个整数类型的模板参数。
通过这一选项,关键字typename被生成用来类类型的每一个模板参数。
With this option, the keyword typename is generated for every template parameter of type class.
图5.创建一个类类型的模板参数。
该转换还提供了一个选项来为类类型的模板参数生成替换class 的关键字。
The transformation also provides an option to generate the keyword in place of class for template parameters of type class.
为了使这个模板更加安全,我按照如下方法确定了参数的数据类型。
To make this template even safer, I data type the parameter as follows.
建立一个绑定类型模板并将其命名为ShelvesList通过设定参数值t为Shelf经其与类List联系起来。
Create a template binding class named ShelvesList with a binding to the List class by setting the parameter t to Shelf.
如何定义具有数量可变的参数(每个参数的类型可能不同)的模板化类或函数?
How do you define a templated class or a function with a variable number of arguments, each with a potentially different type?
您也可以使用模板参数T来定义一个属性类型,用同样的方式它也可以用作定义该种方式的回转类型。
You can also use the template parameter T for an attribute’s type, in the same way as it was used for the method’s return type.
一个非常重要的问题是询问模板函数,这些形式上的模板参数会被类型集合正确的取代,而不仅仅是STL算法。
One very important question to ask about any template function, not just about STL algorithms, is what the set of types is that may correctly be substituted for the formal template parameters.
模板函数总是用完全参数化的类型指定的。
Template functions are always specified with fully parameterized types.
使用模板返回类型或参数类型的函数。
当实例化一个模板,不完整的参数类型成员应该可见吗?
When instantiating a template, should members of its incomplete argument types be visible?
getSignatureInstance()方法实际地构建新的泛型类模板,然后为参数类型的具体列表实例化这些模板。
The getSignatureInstance() method is what actually builds new generic class templates and then instantiates these templates for specific lists of parameter types.
模板函数GetMul,它使用模板类型的参数,还有返回类型。
A template function GetMul with template type arguments and a return type as well.
首先调用f的模板化版本,第一个参数的类型是字符串,作为大小可变的参数提供字符和双精度值。
The first time around, the templated version of f is called, with a string as the first argument type, and the character and double are packed off as the variable size argument.
添加一个名为get的方法。在此方法中,使其返回类型为模板参数t(如图4所示),然后输入参数名字index,其类型为int。
Add a method called get with return type as the template parameter t from the method (as shown in Figure 4), and an input parameter named index whose type is int.
你可以在模板中定义组件类型,或者你可以使用组件标注去定义组件类型和参数为组件产生一个实例变量。
You can define the type of component inside template, or you can create an instance variable for the component and use the component annotation to define the component type and parameters.
他本来想要更强的模板参数的静态类型检验。
He would have liked stronger static type checking of template arguments.
让合成模板接受一个可调用内建类型或者一个mpl序列作为第一个模板参数是否安全?
Is it safe to have the synthesis templates take a callable builtin type or an MPL sequence as the first template argument?
让合成模板接受一个可调用内建类型或者一个mpl序列作为第一个模板参数是否安全?
Is it safe to have the synthesis templates take a callable builtin type or an MPL sequence as the first template argument?
应用推荐