我在一些地方看到过这种情况,为了确认我没有疯,我 寻找其他示例。显然这也可以有其他风格,例如 operator+ <>
但是,我在任何地方都没有看到它是什么,所以我想我应该问一下
operator<<>(
代码>:-)
I have seen this in a few places, and to confirm I wasn't crazy, I looked for other examples. Apparently this can come in other flavors as well, eg operator+ <>
.
However, nothing I have seen anywhere mentions what it is, so I thought I'd ask.
It's not the easiest thing to google operator<< <>(
:-)
发布评论
评论(1)
声明中函数名称(包括运算符,如
operator<<
)后面的<>
表明它是函数模板特化。例如,对于普通的函数模板:(请注意,尖括号中可能列出了模板参数,具体取决于函数模板的专门化方式)
<>
也可以用在函数之后当存在通常在重载解析中更好匹配的非模板函数时,调用函数以显式调用函数模板时的名称:因此,operator<< <> 不是运算符。
<>
after a function name (including an operator, likeoperator<<
) in a declaration indicates that it is a function template specialization. For example, with an ordinary function template:(note that the angle brackets might have template arguments listed in them, depending on how the function template is specialized)
<>
can also be used after a function name when calling a function to explicitly call a function template when there is a non-template function that would ordinarily be a better match in overload resolution:So,
operator<< <>
isn't an operator.