Boost logo

Boost :

Subject: Re: [boost] [type traits] Strange behaviour of comparison operators with pointers
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-06-20 02:12:49


2011/6/18 Frédéric Bron <frederic.bron_at_[hidden]>

> >> Then there is no way to predict if it is possible to compare lhs and
> >> rhs based only on their types.
> >
> > Why do you write this ? Just because 0 can be an integer or a null
> pointer
> > in C++ does not mean the above.
>
> Here it is not literal 0 that can be an integer or a null pointer it
> is an const integer of value 0 that can also be considered as a null
> pointer... It seems to me that it makes a difference.
> If I tell you can you compare "int const" with "int*", you would
> probably answer "no" but if the "int const" is 0 the answer is false.
>
> >> The general rule is that it is not
> >> possible so that this is what I propose to use for the type trait
> >> extension detecting the possibility to call comparison operators on
> >> given types.
> >
> > To what does "this" refer in your previous sentence ?
>
> I mean that I propose can_call_equal (or whatever name...) < int
> const, int * >::value to be false even if there is a possibility for
> comparing some int const with int*.
>

I think of these operator type traits as specifically answering the query

"Is make<T>() [op] make<U>() a compilable (syntactically well-formed?)
expression?"

with

template< class T > T make();

which is consistent with your proposition; i.e., I agree.

- Jeff


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