【发布时间】:2012-01-30 12:49:22
【问题描述】:
祝大家节日快乐。
我一直在研究 C++ 预处理器序列(使用 boost)来帮助我生成基于运算符的函子。到目前为止,我已经完成了源代码,但是我很难找到识别这些函子的最合适的关键字。
更具体地说,在查看 C++0x 草案后,我没有为以下运算符找到最合适的(唯一)名称:
- -> 和 .在草案中都称为:类成员运算符
- ->* 和 .* 都被称为:指向成员运算符的指针
你认为你能帮我更好地命名它们吗?
我使用的参考文献:
- C++0x 草案(可在线查找)
- "boost/proto/operators.hpp" 标头包含大多数可重载运算符。
- 来自 Wikipedia 的 Operators in C and 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:我曾经和你一样是程序员。然后我在膝盖中了一个箭头操作员......
-
@ChrisParton “曾经是”是什么意思,你现在是什么?你为什么要做那个膝盖部分? 0_o
-
@Mr.Anubis:对不起,我知道这太糟糕了哈哈。我无法抗拒:)
-
@Mr.Anubis:《天际》游戏中有很多士兵都说了类似的话。在线解释它已成为一种令人讨厌的趋势。我在扯掉它。我仍然是一名程序员,我的膝盖很好:)