Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-05-21 09:37:02


From: "David B. Held" <dheld_at_[hidden]>
> "Joe Gottman" <jgottman_at_[hidden]> wrote in message
>
> > template<class T>
> > bool operator==(intrusive_ptr<T> const & a, T * b);
>
> > I'm curious why the pointer parameters are of type T* and not
> > T const *.
>
> Because that would not allow comparisons between types that
> are not T const*. Take T == int. With T*, you can compare int*.
> With T == int const, you get int const*. If you use T const* instead,
> you won't ever be able to compare int*.

int * p1(0);
int const * p2(p1); // OK

Notice also that T for instrusive_ptr<T> and for T * is one and
the same, so you can't compare intrusive_ptr<T> with T const *.
You could only compare intrusive_ptr<T const> with T const *.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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