From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-01-03 23:21:09
"Jeremy Maitin-Shepard" <jbms_at_[hidden]> wrote in message
> "Thorsten Ottosen" <nesotto_at_[hidden]> writes:
> > [snip]
> > 2) in generic code, const T* and const smart_ptr<T> are not equal and I
> > need traits to deal with different syntax
> It seems you are being confused by your placement of the const keyword.
> "const shared_ptr<T>" is equivalent to "shared_ptr<T> const",
> but "const T *" is not equivalent to "T * const".
> "const T *" is equivalent to "T const *".
> However, if you have:
> typedef T *pointer;
> Then, "const pointer" is equivalent to "pointer const" is equivalent to
> "T * const".
> To get the const behavior of "const T *" (or "T const *"), i.e. const
> pointee, use "shared_ptr<T const>".
I see your point and know that that is how it works.
> To get the const behavior of "T * const", i.e. const pointer,
> use "shared_ptr<T> const" or "const shared_ptr<T>".
> For generic programming purposes, shared_ptr<T> does in fact work
> equivalently to boost::add_const<T>::type. With your proposed change,
> however, it would not.
Is this used anywhere? If so, could there be work-arounds?
This is really a cruial question. I would like to see your reply to
all the other concerns, I mentioned earlier.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk