Subject: Re: [boost] [Pointer Container] Modification of pointer containers to allow const elements
From: Gerardo Hernandez (g.hernandez_at_[hidden])
Date: 2010-10-15 19:39:58


2010/10/15 Scott McMurray <me22.ca+boost_at_[hidden]>:
> On Fri, Oct 15, 2010 at 13:04, Gerardo Hernandez
> <g.hernandez_at_[hidden]> wrote:
>>
>> 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.
>
Ok. But static_cast are not present when when inserting. So methods
like ptr_sequence_adapter::push_back or ptr_map_adapter::insert will
see a const_cast added too.

>
> 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.
>

Indeed. Accessors that return iterators could add const_cast too.

So we have two options:
1) Scatter const_cast throught the code
2) Use mpl::if_ at the expense of one additional template
instantiation (Would that be so painful?)

Additional opinions are largely welcomed.

Gerardo.