C++ Logo


Advanced search

Re: Iterators of the class template std::array

From: Andrew Schepler <aschepler_at_[hidden]>
Date: Sun, 26 Sep 2021 10:00:12 -0400
On Sun, Sep 26, 2021 at 9:14 AM Edward Catmur via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> On Sun, 26 Sep 2021, 12:27 Vladimir Grigoriev via Std-Discussion, <
> std-discussion_at_[hidden]> wrote:
>> It would be useful if there was adopted in the Standard that iterators
>> of two instantiations std::array<T, N1> and std::array<T, N2> had the same
>> types of iterators.. In this case we could use lists of iterators for
>> instantiations of std::array that have the same type of the first template
>> parameter.
> If you wish to erase the extent of the array, you can use a dynamic span
> iterator.

Although it might not be the same type as std::array<T,N1>::iterator or
std::array<T,N2>::iterator, there's already an even simpler iterator type
which can be used with both arrays, erasing the array extent. That iterator
type is of course "T*", as obtained from (data()+k).

-- Andrew Schepler

Received on 2021-09-26 09:00:25