Boost logo

Boost :

Subject: Re: [boost] [TypeTraits] is it possible to add something to boost.type_traits?
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-12-16 22:10:36


On Wed, Dec 16, 2009 at 5:58 PM, Edward Diener <eldiener_at_[hidden]> wrote:
> 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.
>

I think, actually, if operator, is implemented for T, then the
comma-operator-trick no longer works, and we can't figure out most/any
of the other operators either. See
http://cpp-next.com/archive/2009/10/this-week-in-boost/#more-746

Tony


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