C++学习记录——侯捷泛型编程第二讲
前言
参考网站:https://en.cppreference.com/w/cpp/language/operators
原文节选
Overloaded operators
When an operator appears in an expression, and at least one of its operands has a class type or an enumeration type, then overload resolution is used to determine the user-defined function to be called among all the functions whose signatures match the following:
(当运算符出现在表达式中,且其至少一个操作数具有类类型或枚举类型时,则使用重载解析来确定要在签名与以下内容匹配的所有函数中调用的用户定义函数:)
(在该表中,@是一个占位符,表示所有匹配的运算符:@a中的所有前缀运算符、@中除->之外的所有后缀运算符、=之外的所有中缀运算符a@b)
(此外,对于比较运算符==,!=,<,>,<=,>=,<=>,重载解析还考虑从运算符==或运算符<=>生成的重写候选。)
(注意:对于co_await的重载,(自C++20以来)用户定义的转换函数、用户定义的文本、分配和解除分配,请参见它们各自的文章。
可以使用函数表示法调用重载运算符(但不是内置运算符):)