Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2000-01-25 16:00:06


> Hmm... I mean really hmm. smart_ptr as it stands now says:
>
> shared_ptr(const shared_ptr& r) throw() : px(r.px) { ++*(pn = r.pn); }
>
> Now, will somebody explain to me how can you do:
>
> pn = r.pn;
>
> when pn is not const and r (and therefore r.pn) is const.

The pointer r.pn is const. But what's pointed to is not const. So if we are
talking about shared_ptr<int>, pn is of type "int *" and r.pn is of type
"int * const". There would be a problem if r.pn was a pointer to a const
int, "int const *" or "const int *", but it's not.

    -- Darin


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