wiki:Guidelines/Naming/Operators

Version 4 (modified by Joachim Faulhaber, 12 years ago) ( diff )

--

Operator Names

This page has been created for the extention of Boost.TypeTraits by operator traits to ease an overview over existing naming of operators in the standards 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.
MPU 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 MPU are trying to minimize the differences between and so maximize the consistency. The naming from Boost.Proto is found in other boost libraries, e.g. accumulator.

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:

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 consitency 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.

Note: See TracWiki for help on using the wiki.