Subject: Re: [boost] [Pointer Container] Modification of pointer containers to allow const elements
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2010-10-15 17:35:30
On Fri, Oct 15, 2010 at 13:04, Gerardo Hernandez
> I see the point. But I do not understand the advantage of using a
> single underlying type instead of two (which I presume was also
> Thorsten idea).
It's the same advantage as using the same underlying type for
ptr_vector<int> and ptr_vector<string>: instantiating less code.
> Using always void* would not only require a lot of
> const_cast when returning data from the containers
Not a big deal, since it already has to static_cast everywhere when
returning data from the containers.
> but also think that
> ptr_vector<T>::iterator must be of different type as ptr_vector<const
> T>::iterator, as:
> boost::ptr_vector<const int> v;
> v.push_back(new int);
> (*v.begin()) = 2;
> shall also be compiler error, as the container contains const elements.
Again, ptr_vector<int> and ptr_vector<string> also need different
iterators, despite using the same underlying type, so ptr_vector<int>
and ptr_vector<const int> will have different iterator types as well,
even though they'd both wrap the same internal iterator type. And
just like above, they'll just need to const_cast in addition to the
static_casts that are already there.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk