模板参数:在编程语言(尤其是 C++)中,用来给模板提供类型或常量等信息的占位符,使同一份代码可以根据不同输入生成不同的具体版本。常见有 type template parameter(类型模板参数)、non-type template parameter(非类型模板参数) 等。
/ˈtɛmpleɪt pəˈræmɪtər/
A template parameter can be a type.
模板参数可以是一个类型。
By adjusting the template parameter, the same function can work efficiently for both integers and floating-point numbers without duplicating code.
通过调整模板参数,同一个函数无需重复代码就能高效地同时适用于整数和浮点数。
由 template(模板) + parameter(参数) 组合而成。template 原指“样板/模板”,在编程中引申为“可生成多种具体实现的代码框架”;parameter 指“输入条件/参数”。合在一起即“用于模板生成具体版本的参数”。