Boost logo

Boost :

Subject: Re: [boost] [TypeTraits] is it possible to add something to boost.type_traits?
From: Edward Diener (eldiener_at_[hidden])
Date: 2009-12-16 17:58:14


Frédéric Bron wrote:
>> It would really be nice to have type_traits for all the possible
>> user-defined operators.
>
> For the moment, I am working on <, <=, >, >=, ==, !=, +, -, *, /, %.
> The main difficulty is to treat operators that are not defined for
> built-in types as a specialization is to be provided in each case. For
> %, I have a very long list of exceptions.
> When you say all operators, do you mean &&, || and bitwise operators?
> Can you enumerate the operators you're thinking of?

The operators which can be user-defined as specified in the C++
standard. These are given in 13.5 1, as:

new delete new[] delete[]
+ - * / % ˆ & | ˜
! = < > += -= *= /= %=
ˆ= &= |= << >> >>= <<= == !=
<= >= && || ++ -- , ->* ->
() []

I personally don't need the first four for what I am working on, but it
would be real nice if type_traits exrensions could discover whether any
of the remaining ones are defined by the user for a particular T.

If the technique of discovering a unary operator, as given in
is_incrementable in boost::detail, is known then it seems like it should
work for all the unary operators. Similarly if the technique can be
expanded to a single binary operator, then it seems like it should work
for all the binary operators. I do understand that one technique, as
given by Eric Niebler, involves a creative use of the ',' operator
through overloading, it so maybe the technique would have to be modified
in discovering if the ',' operator itself is overloaded for a given T.


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