C++官方运算符名称/关键字

39

大家节日快乐。

我一直在使用 Boost 编写 C++ 预处理序列,以帮助我生成基于运算符的函数对象。到目前为止,我已经完成了源码,但是我遇到了麻烦,无法找到最合适的关键字来标识这些函数对象。

具体来说,经过审查 C++0x 草案后,我未能找到以下运算符的最合适(独特)名称:

  • -> 和 . ,它们在草案中都被称为类成员运算符
  • ->* 和 .* ,它们都被称为指向成员运算符

你认为你能帮我更好地命名它们吗?

我所使用的参考资料:

  1. C++0x 草案(可以在线找到)
  2. 包含大部分可重载运算符的 boost/proto/operators.hpp 头文件。
  3. 来自维基百科的 C 和 C++ 的运算符,也提供了以下名称
    • . 结构体引用
    • -> 结构体解引用
    • ->* 和 .* 成员指针

以下是我所创建的列表。如有其他建议,将不胜感激。

 Symbol        Keyword           Description
++      , post_increment      , post increment
--      , post_decrement      , post decrement
++      , pre_increment       , pre increment
--      , pre_decrement       , pre decrement
+       , unary_plus          , additive promotion
-       , unary_minus         , additive inversion
!       , negate              , logical negation
~       , complement          , complement
*       , indirect            , indirection
&       , address_of          , address of
+       , add                 , addition
-       , subtract            , subtraction
*       , multiplies          , multiplication
/       , divides             , division
%       , modulus             , modulo
==      , equal               , equality
!=      , inequal             , inequality
>       , greater             , greater than
<       , less                , less than
>=      , greater_equal       , greater or equal than
<=      , less_equal          , less or equal than
&&      , logical_and         , logical and
||      , logical_or          , logical or
&       , bitwise_and         , bitwise and
|       , bitwise_or          , bitwise inclusive or
^       , bitwise_xor         , bitwise exclusive or
<<      , left_shift          , left shift
>>      , right_shift         , right shift
+=      , add_assign          , addition assignment
-=      , subtract_assign     , subtractions assignment
*=      , multiplies_assign   , multiplication assignment
/=      , divides_assign      , division assignment
%=      , modulus_assign      , modulo assignment
>>=     , right_shift_assign  , right shift assignment
<<=     , left_shift_assign   , left shift assignment
&=      , bitwise_and_assign  , bitwise and assignment
^=      , bitwise_or_assign   , bitwise exclusive or assignment
|=      , bitwise_or_assign   , bitwise inclusive or assignment
->*     , arrow_indirect      , pointer to member
,       , comma               , comma
=       , assign              , assignment
[]      , subscript           , subscription
->      , arrow               , class member
.       , dot                 , class member
.*      , dot_indirect        , pointer to member

我记得这个只是(不确定):-> 被称为箭头运算符(保护你的眼睛 :D)(通过指针访问成员)。 - Mr.Anubis
5
@Mr.Anubis: 我曾经和你一样是一名程序员。然后我膝盖中了一个箭头运算符... - Chris Parton
1
@ChrisParton,“Used to be”是什么意思,你现在是什么?为什么你要做那个膝盖部位?0_o - Mr.Anubis
@Mr.Anubis:抱歉,我知道它很糟糕哈哈。我忍不住了 :) - Chris Parton
1
@Mr.Anubis:游戏《上古卷轴5:天际》中有很多士兵说着类似的话。这已经成为了一种令人讨厌的趋势,被网友们大量引用。我也曾效仿过。我依然是一名程序员,我的膝盖非常健康 :) - Chris Parton
显示剩余5条评论
1个回答

11

请尝试参考这个网站

关键字和操作符还包括new、delete和casting。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接