Version 7 (modified by 12 years ago) ( diff ) | ,
---|
Operator Names
This page has been created on occasion of the extension of Boost.TypeTraits by operator traits to give an overview over existing naming of operators and related operator-fuctors in the standard and boost libraries. The purpose of the page is to collect differences and support convergence.
Column | Comment |
---|---|
op | The operator sign |
alt | An alternative tokens, if available |
type_traits | boost::type_traits naming as proposed by Frédéric Bron. |
MUP | Most Unifying Proposal |
std | = : Equal naming in the standard
|
=* : Equal naming, new in next standard.
| |
proto | = : Equal naming in boost::proto
|
*_p : Partial equality except for a prefix or postfix
| |
operator | Corresponding naming of concepts from boost::operator |
The names in column MUP are trying to minimize the differences between names and maximize the naming consistency. The naming from Boost.Proto is found in other boost libraries, e.g. accumulator and phoenix.
op | alt | type_traits | MUP | std | proto | boost::operator |
---|---|---|---|---|---|---|
== | equal_to | equal_to | = | = | equality_comparable | |
!= | not_eq | not_equal_to | not_equal_to | = | = | |
< | less | less | = | = | less_than_comparable | |
<= | less_equal | less_equal | = | = | ||
> | greater | greater | = | = | ||
>= | greater_equal | greater_equal | = | = | ||
+ | plus | plus | = | = | addable | |
- | minus | minus | = | = | subtractable | |
* | multiplies | multiplies | = | = | multipliable | |
/ | divides | divides | = | = | dividable | |
% | modulus | modulus | = | = | modable | |
+= | plus_equal | plus_assign | *_assign | |||
-= | minus_equal | minus_assign | *_assign | |||
*= | multiplies_equal | multiplies_assign | *_assign | |||
/= | divides_equal | divides_assign | *_assign | |||
%= | modulus_equal | modulus_assign | *_assign | |||
&& | and | logical_and | logical_and | = | = | |
|| | or | logical_or | logical_or | = | = | |
& | bitand | bit_and | bit_and | = * | bitwise_* | andable |
| | bitor | bit_or | bit_or | = * | bitwise_* | orable |
^ | bit_xor | bit_xor | = * | bitwise_* | xorable | |
<< | left_shift | left_shift | shift_left | left_shiftable | ||
>> | right_shift | right_shift | shift_right | right_shiftable | ||
&= | and_eq | bit_and_equal | bit_and_assign | bitwise_and_assign | ||
|= | or_eq | bit_or_equal | bit_or_assign | bitwise_or_assign | ||
^= | xor_eq | bit_xor_equal | bit_xor_assign | bitwise_xor_assign | ||
<<= | left_shift_equal | left_shift_assign | shift_left_assign | |||
>>= | right_shift_equal | right_shift_assign | shift_right_assign | |||
++ | prefix_increment | pre_increment | pre_inc | incrementable | ||
-- | prefix_decrement | pre_decrement | pre_dec | decrementable | ||
+ | unary_plus | unary_plus | = | |||
- | unary_minus | negate | negate | negate | ||
! | not | logical_not | logical_not | = | logical_not | |
~ | compl | complement | complement | complement | ||
* | dereference | dereference | dereference | |||
++ | postfix_increment | post_increment | post_inc | |||
-- | postfix_decrement | post_decrement | post_dec |
There are some conflicts that have been solved under these rationals.
An name is chosen along these priorities
- If the name exists in the current c++ standard.
- If the name exists in the new upcoming c++ standard.
- Name is not given by 1 or 2 but is used in proto
- For the remaining conflicts
- Does the name follow general boost naming conventions?
- Can it be completed to a typical concept name "conceptified". E.g. left_shift -> left_shiftable
o= | op_equal vs. op_assign | proto and other boost::libs agree on op_assign . We can better conceptify to OpAssignable
|
bit vs. bitwise | bitwise seems to be more "natural" but some naming in the standard prefers bit_ prefix | |
<< >> | shift_xxx or xxx_shift | goes to xxx_shift, because we can conceptify to xxx_shiftable more nicely. |
++ -- | pre/postfix vs. pre/post | goes to pre_in/decrement post_in/decrement. Seems simpler and more natural. |
A higher naming consistency could be reached, if the standard was changed for 3 names:
// 20.8.7, bitwise operations: template <class T> struct bit_and; template <class T> struct bit_or; template <class T> struct bit_xor;
In this case all the bit
prefixes could be replaced by bitwise
, so it would be consistent with all proto names referring to bitwise operations. Note that "20.8.7, bitwise operations" are all part of the new upcoming standard and could still be changed.