C++ Logo

std-proposals

Advanced search

Re: std::iterator_static_cast & std::iterator_const_cast?

From: Jake Arkinstall <jake.arkinstall_at_[hidden]>
Date: Thu, 2 May 2019 15:25:50 +0100
In line with std::make_reverse_iterator, it would make sense to name such a
method std::make_const_iterator.

I certainly would not accept a standard function that does the opposite of
that, turning a const iterator into an iterator. If people want to do
stupid things then they're welcome to, but the standard shouldn't help them
to do it.

Though this does bring up a more fundamental question. You have an iterator
to a container, so you've already performed a non-const call to obtain
that. What's the benefit of converting it to a const iterator after that?

On Thu, 2 May 2019, 15:16 sotrdg sotrdg via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> Why does the standard not have std::iterator_const_cast? There is no
> standard way to convert type like std::deque<std::size_t>::const_iterator
> to std::deque<std::size_t>::iterator vice versa or
> std::deque<std::size_t>::const_reverse_iterator to
> std::deque<std::size_t>:: reverse_iterator
>
>
>
> std::iterator_static_cast can also solve the definition problem of
> contiguous_iterator, if an iterator T can std::iterator_static_cast to
> typename std::iterator_traits<T>::pointer and void*, then it is a
> contiguous_iterator.
>
>
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> http://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2019-05-02 09:27:37