且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用透明的std函数对象时,我们是否仍需要写空尖括号?

更新时间:2023-11-28 14:27:28

GCC错误.已经存在错误报告.

GCC is wrong. There is already a bug report.

[dcl.type.simple]/2 说:

类型说明符,格式为typename opt 嵌套名称说明符 opt 模板名称是推导的类类型([dcl.type.class.deduct])的占位符.

A type-specifier of the form typenameoptnested-name-specifieropttemplate-name is a placeholder for a deduced class type ([dcl.type.class.deduct]).

[dcl.type.class.deduct]/2 说:

推导类类型的占位符也可以在 new-type-id type-id new-expression 作为显式类型转换(功能符号)中的 simple-type-specifier ([expr. type.conv]),或作为 template-parameter parameter-declaration 中的 type-specifier .推导的类类型的占位符不得出现在任何其他上下文中.

A placeholder for a deduced class type can also be used in the type-specifier-seq in the new-type-id or type-id of a new-expression, as the simple-type-specifier in an explicit type conversion (functional notation) ([expr.type.conv]), or as the type-specifier in the parameter-declaration of a template-parameter. A placeholder for a deduced class type shall not appear in any other context.

允许这种使用.

[temp.arg]/4 描述了语法错误,要求提供 template-id ,但没有<>.但是,此处std::greater不能解析为 template-id ,因此该段落不适用.

[temp.arg]/4 describes the syntax error that a template-id is required but there is no <>. However here std::greater is not resolved as a template-id so that paragraph does not apply.