| 1 | = Introduction = |
| 2 | |
| 3 | This page gives different proposals to name the traits that answer the following questions: |
| 4 | - if "@" is a binary operator, can you write somewhere in your code "lhs @ rhs", |
| 5 | - if "@" is a prefix unary operator, can you write somewhere in your code "@ rhs", |
| 6 | - if "@" is a postfix unary operator, can you write somewhere in your code "lhs @", |
| 7 | |
| 8 | lhs and rhs being of any types provided as template parameters to the trait. Optionnaly, the traits can also answer if the operator return type is convertible to some type. |
| 9 | |
| 10 | |
| 11 | = Proposals = |
| 12 | |
| 13 | ||='''operator''' =||='''A''': review =||='''B''' =|| |
| 14 | ||`+` ||has_operator_plus ||can_call_addition || |
| 15 | ||`-` ||has_operator_minus ||can_call_subtraction || |
| 16 | ||`*` ||has_operator_multiplies ||can_call_multiplication || |
| 17 | ||`/` ||has_operator_divides ||can_call_division || |
| 18 | ||`%` ||has_operator_modulus ||can_call_modulus || |
| 19 | ||`+=` ||has_operator_plus_equal ||can_call_addition_assignment || |
| 20 | ||`-=` ||has_operator_minus_equal ||can_call_subtraction_assignment || |
| 21 | ||`*=` ||has_operator_multiplies_equal ||can_call_multiplication_assignment || |
| 22 | ||`/=` ||has_operator_divides_equal ||can_call_division_assignment || |
| 23 | ||`%=` ||has_operator_modulus_equal ||can_call_modulus_assignment || |
| 24 | ||`&` ||has_operator_bit_and ||can_call_bitwise_and || |
| 25 | ||`|` ||has_operator_bit_or ||can_call_bitwise_or || |
| 26 | ||`^` ||has_operator_bit_xor ||can_call_bitwise_xor || |
| 27 | ||`&=` ||has_operator_bit_and_equal ||can_call_bitwise_and_assignment || |
| 28 | ||`|=` ||has_operator_bit_or_equal ||can_call_bitwise_or_assignment || |
| 29 | ||`^=` ||has_operator_bit_xor_equal ||can_call_bitwise_xor_assignment || |
| 30 | ||`<<` ||has_operator_left_shift ||can_call_shift_left || |
| 31 | ||`>>` ||has_operator_right_shift ||can_call_shift_right || |
| 32 | ||`<<=` ||has_operator_left_shift_equal ||can_call_shift_left_assignment || |
| 33 | ||`>>=` ||has_operator_right_shift_equal ||can_call_shift_right_assignment || |
| 34 | ||`==` ||has_operator_equal_to ||can_call_equal || |
| 35 | ||`!=` ||has_operator_not_equal_to ||can_call_not_equal || |
| 36 | ||`<` ||has_operator_less ||can_call_less || |
| 37 | ||`<=` ||has_operator_less_equal ||can_call_less_equal || |
| 38 | ||`>` ||has_operator_greater ||can_call_greater || |
| 39 | ||`>=` ||has_operator_greater_equal ||can_call_greater_equal || |
| 40 | ||`&&` ||has_operator_logical_and ||can_call_and || |
| 41 | ||`||` ||has_operator_logical_or ||can_call_or || |
| 42 | ||`!` ||has_operator_logical_not ||can_call_not || |
| 43 | ||`+` ||has_operator_unary_plus ||can_call_unary_plus || |
| 44 | ||`-` ||has_operator_unary_minus ||can_call_unary_minus || |
| 45 | ||`~` ||has_operator_complement ||can_call_complement || |
| 46 | ||`*` ||has_operator_dereference ||can_call_dereference || |
| 47 | ||`++` ||has_operator_prefix_increment ||can_call_pre_increment || |
| 48 | ||`--` ||has_operator_prefix_decrement ||can_call_pre_decrement || |
| 49 | ||`++` ||has_operator_postfix_increment ||can_call_post_increment || |
| 50 | ||`--` ||has_operator_postfix_decrement ||can_call_post_decrement || |
| 51 | |
| 52 | |
| 53 | = Comments during the official review = |
| 54 | |
| 55 | ||='''date''' =||='''who''' =||='''comment''' =|| |
| 56 | || 14/03/2011 || vijayan12 || replace _equal by _assign || |
| 57 | || 14/03/2011 || vicente.bote || replace _equal by _assign || |
| 58 | || 14/03/2011 || vicente.bote || shift -> bit_left/right_shift || |
| 59 | || 14/03/2011 || vicente.bote || complement -> bit_not || |
| 60 | || 14/03/2011 || vicente.bote || prefix_ -> pre_, postfix_ -> post_ || |
| 61 | || 15/03/2011 || vicente.bote || &,|,^,~,<<,>> are bit operators and all should be named following the same schema. || |
| 62 | || 15/03/2011 || thom.helle || WRT naming i think we should strive for consistent naming in overall boost, not just the type_traits library. Proto, for example, names the operators as well, as does Boost.Operator. FWIW both libraries agree on left_shift/right_shift. || |
| 63 | || 15/03/2011 || jhellrun || I prefer op_equal as well, but it's not a strong preference. || |
| 64 | || 15/03/2011 || jhellrun || I, too, prefer shift_left and shift_right, given their ubiquity related to std::iostream. || |
| 65 | || 15/03/2011 || pbristo || There would seem to me to be a very strong case for having the same names as in Boost.Proto and Boost.Operator. || |
| 66 | || 15/03/2011 || vicente.bote || I have a little problem with the has_operator_ prefix on the name of the traits. The traits is not checking the class parameter(s) has/have an operator, but that the application of the operator to this/these types is syntactically correct. E.g. has_operator_plus<int, double>::value neither int nor double have an operator+. applicable_operator_plus<int, double>::value or can_apply_operator_plus could be an option. || |
| 67 | || 16/03/2011 || eldiene || has_ is fine || |
| 68 | || 16/03/2011 || robert.stewar || replace _equal by _assign || |
| 69 | || 16/03/2011 || robert.stewar || plus_equal -> add_assign || |
| 70 | || 16/03/2011 || robert.stewar || multiplies -> multiply, divides -> divide || |
| 71 | || 16/03/2011 || robert.stewar || bit -> bitwise || |
| 72 | || 16/03/2011 || robert.stewar || prefer direction followed by shift (right/left_shift) than shift followed by direction || |
| 73 | || 16/03/2011 || robert.stewar || I generally like the names from Proto. Consistency would be nice, but consider the names as they are likely to be standardized. Better to get the names "right" now. For example, I think "postfix_increment" is a likely name for standardization, while "post_inc" is not. || |
| 74 | || 16/03/2011 || joel.falco || add typedefs for proto consistency || |
| 75 | || 16/03/2011 || vicente.bote || do not mix operators and concepts (equality_comparable, addable, less_than_comparable) which are adjectives || |
| 76 | || 16/03/2011 || vicente.bote || std::ratio uses add, subtract, multiply and divide, this corresponds to verbs not to nouns and have a semantic associated. Boost.MPL has also some names for arithmetic operators. It uses plus, minus, times and divides. I think that that the names we are looking for should be names. || |
| 77 | || 16/03/2011 || vicente.bote || bit -> bitwise || |
| 78 | || 16/03/2011 || vicente.bote || prefer direction followed by shift (right/left_shift) than shift followed by direction || |
| 79 | || 16/03/2011 || vicente.bote || used in standard: prefix/postfix increment/decrement, pre/post increment/decrement || |
| 80 | || 17/03/2011 || boost.rege || names proposed are consistent || |
| 81 | || 18/03/2011 || afojg || has_operator_xxx is imprecise and should be operator_xxx_applicable_to or operator_xxx_callable_on instead? || |
| 82 | || 18/03/2011 || eldiene || IMO nobody is going to be comfortable with 'operator_xxx_callable_on' as opposed to 'has_operator_xxx'. || |
| 83 | || 18/03/2011 || jeffrey.hellrun || prefers is_xxxable to has_operator_ || |
| 84 | || 18/03/2011 || jeffrey.hellrun || prefers plus, minus to add, substract || |
| 85 | || 18/03/2011 || jeffrey.hellrun || prefers plus_equal to plus_assign || |
| 86 | || 18/03/2011 || jeffrey.hellrun || prefers post/pre_increment/decrement to postfix/prefix_increment/decrement || |
| 87 | || 18/03/2011 || jeffrey.hellrun || prefers bit_ to bitwise_ || |
| 88 | || 18/03/2011 || afojg || has_operator_xxx seems to be imprecise and misleading || |
| 89 | || 18/03/2011 || afojg || has_operator_xxx introduces a redundant prefix 'has_operator' || |
| 90 | || 18/03/2011 || afojg || plus_assign_callable or plus_assignable || |
| 91 | || 18/03/2011 || boost.rege || plus_assignable -> is_plus_assignable || |
| 92 | || 18/03/2011 || robert.stewar || plus_assignable -> is_add_assignable || |
| 93 | || 18/03/2011 || robert.stewar || can_assign_sum/difference/product/quotient || |
| 94 | || 18/03/2011 || robert.stewar || can_add_and_assign/subtract_and_assign/multiply_and_assign/divide_and_assign || |
| 95 | || 18/03/2011 || vicente.bote || can_add/multiply/left_shift/post_increase/add_assign/subtract_assign/multiply_assign/divide_assign || |
| 96 | || 19/03/2011 || afojg || The name has_operator_xxx misleads to the assumption, that the signature of an operator can be checked directly. At least naive users (like me;) may fall into this trap. || |
| 97 | || 19/03/2011 || afojg || remove operator_ || |
| 98 | || 19/03/2011 || afojg || (1) Consistency with general math and scientific knowledge (2) Consistency with standards (2.1) Consistency with c++ standards (2.2) Consistency with boost (2.3) Consistency with other standards, if they exist (3) Conciseness (3.1) Precise and descriptive (3.2) Adequate level of abstraction (3.3) Reduced for unnecessary redundancies (3.4) Relatedness to other names with similar meanings. || |
| 99 | || 19/03/2011 || afojg || +: cross, -: dash, *: star, /: slash || |
| 100 | || 19/03/2011 || spillne || is_callable<plus, LeftOperandType, RightOperandType>, result_of<plus, LeftOperandType, RightOperandType, ReturnType>, retval_convertible_to<plus, LeftOperand, RightOperandType, EquivalentReturnType>, is_prefix_callable<plusplus, OperandType>, is_postfix_callable<plusplus, OperandType> || |
| 101 | || 21/03/2011 || afojg || https://svn.boost.org/trac/boost/wiki/Guidelines/Naming/Operators || |
| 102 | || 24/03/2011 || afojg || + cross, addition, set union, concatenation, ... || |
| 103 | || 24/03/2011 || afojg || - dash, subtraction, set difference, deletion ... || |
| 104 | || 24/03/2011 || afojg || * star, multiplication, intersection, Cartesian product ... || |
| 105 | || 24/03/2011 || afojg || / slash, division, factorization, ... || |
| 106 | || 28/03/2011 || dherrin || has_op_xxx || |
| 107 | || 29/03/2011 || afojg || is_xxx_callabe || |
| 108 | || 29/03/2011 || afojg || can_call_equal_to || |