On 14 May 2013 13:51, Paolo Carlini wrote:
> On 05/14/2013 02:40 PM, Paolo Carlini wrote:
>>
>> Then I suppose that the correct way to move forward to C++11 the
>> ext/pointer.h stuff would be adding a pointer_traits specialization for
>> those pointer-like types, which would also wrap the cast operations in
>> pointer_to. Then, in __normal_iterator::_M_const_cast use pointer_traits.
>
> ... and even more interestingly, looks like Jonathan already did most of
> this, at the end of ext/pointer.h. Oh my ;)

I forgot that I had marked your first mail in this thread, meaning to
come back to it when I had time to understand the vector::pointer
issue that I supposedly had under control :-)

I'd forgotten about the existence of __const_pointer_cast etc. in
<ext/cast.h> ... I agree that in C++11 mode
__normal_iterator::_M_const_cast should not rely on the existence of a
get() member on the custom pointer, because that's not required to
exist, and you can do it like this instead:

using PT = pointer_traits<ToType>;
auto to = PT::pointer_to(const_cast<PT::element_type&>(*from));

Reply via email to