
On Wed, Feb 15, 2012 at 5:40 PM, Olaf van der Spek <ml@vdspek.org> wrote:
On Wed, Feb 15, 2012 at 3:30 AM, Julien Nitard <julien.nitard@m4tp.org> wrote:
An std container of references does not compile, a std container of pointers does. In code with dynamic polymorphic type systems pointers get used a lot, and often more than they should.
An std container of (boost/std)::(shared_ptr/unique_ptr) does compile and should be prefered to raw pointers.
Why? If the pointers are non-owning, shared/unique is wrong.
I may just say that you could add weak_ptr to the list to make it look better, but I guess you're right. I just thought (wrongly) that the pointers were owning. Sorry. In the context of the question, though, I was trying to support the fact that raw pointers are "used a lot, and often more than they should". I forgot that we're talking on boost and that your usual metrics and practices won't always hold. Julien