C++ Logo

std-proposals

Advanced search

Re: [std-proposals] `random_access_iterator_accessor` for `std::mdspan`?

From: Ell <ell.ell.se_at_[hidden]>
Date: Thu, 02 Apr 2026 18:48:16 +0000
On Thursday, April 2nd, 2026 at 8:24 PM, Mark Hoemmen via Std-Proposals <std-proposals_at_[hidden]> wrote:

> >> Have you considered adding converting constructors so that users can
> >> go from an iterator-to-nonconst to an iterator-to-const?
> >
> > The proposed wording has the following converting constructors:
> >
> > template<convertible_to<I> I2>
> > constexpr iterator_accessor(iterator_accessor<I2>) noexcept {}
> >
> > I think it's enough to cover it?
>
> The analog of this is enough for `default_accessor`, but that only has
> to deal with pointers. If I is constructible from I2, but I2 is not
> convertible to I, then the same should be true of the accessor. As a
> result, mdspan conversion would work in the same way as accessor
> conversion. This is the design intent of mdspan.
>

Also, iterator_accessor has to deal with pointers as a special case of
iterators, so it should have the same safeguard as default_accessor and
friends against converting a pointer-to-derived to a pointer-to-base.

Received on 2026-04-02 18:48:28