Boost logo

Boost :

Subject: Re: [boost] review request: addition to type_traits library of is_less_comparable<T, U> and others
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2009-12-06 08:17:35


> I am starting again to work on adding new traits to detect if two
> types can be compared (is_less_comparable<T,U> and
> has_operator_less<T,U>). Sorry for the long break but I could not find
> any time for this in the past weeks.
>
> A recent post on the list makes me think that we could enlarge the
> scope of the addition. In fact, here is the list of binary operators
> for which we could implement type trait detection:
>
> * comparisons: <, <=, >, >=, ==, !=
> * arithmetic operations: +, -, *, /, %
> * logical operations: && (and), || (or)
> * bitwise operations: <<, >>, ^ (xor), & (bitand), | (bitor)

I would like to propose the following names for the type traits based
on corresponding names in header <functional>. The first proposed name
for type traits checking only for existence and the second name for
type traits checking for existence and standard behaviour, i.e. the
operator returns non void convertible to something the user can supply
as template parameter (default bool for comparison operators). For
existence, I am quite happy with the names, for existence and standard
behaviour, I would like something shorter...

One could also be in favor of has_operator_less or has_less_operator.
The 1st one is consistant with declaration operator<(...), the 2nd one
is consistant with already existing type trait has_new_operator and
English I suppose.

operator name in <functional> proposed name (existence)
proposed name (existence and non void return type convertible to
something)
< less has_operator_less
operator_less_has_standard_behaviour
<= less_equal has_operator_less_equal
operator_less_equal_has_standard_behaviour
> greater has_operator_greater operator_greater_has_standard_behaviour
>= greater_equal has_operator_greater_equal operator_greater_equal_has_standard_behaviour
== equal_to has_operator_equal_to
operator_equal_to_has_standard_behaviour
!= not_equal_to has_operator_not_equal_to
operator_not_equal_to_has_standard_behaviour
&& logical_and has_operator_and
operator_and_has_standard_behaviour
|| logical_or has_operator_or
operator_or_has_standard_behaviour

+ plus has_operator_plus
operator_plus_has_standard_behaviour
- minus has_operator_minus
operator_minus_has_standard_behaviour
* multiplies has_operator_multiplies
operator_multiplies_has_standard_behaviour
/ divides has_operator_divides
operator_divides_has_standard_behaviour
% modulus has_operator_modulus
operator_modulus_has_standard_behaviour

Please give your feedback and do not hesitate to make other propositions.

Frédéric


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk