Subject: Re: [boost] review request: addition to type_traits library of is_less_comparable<T, U> and others
From: Christian Schladetsch (christian.schladetsch_at_[hidden])
Date: 2009-12-06 09:09:58
2009/12/7 Frédéric Bron <frederic.bron_at_[hidden]>
> > 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
> < less has_operator_less
> <= less_equal has_operator_less_equal
> > greater has_operator_greater
> >= greater_equal has_operator_greater_equal
> == equal_to has_operator_equal_to
> != not_equal_to has_operator_not_equal_to
> && logical_and has_operator_and
> || logical_or has_operator_or
> + plus has_operator_plus
> - minus has_operator_minus
> * multiplies has_operator_multiplies
> / divides has_operator_divides
> % modulus has_operator_modulus
> Please give your feedback and do not hesitate to make other propositions.
How about rationalising over the operators themselves?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk