C++ Logo

std-discussion

Advanced search

Re: Iterators of the class template std::array

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sun, 26 Sep 2021 11:03:31 -0400
On Sun, Sep 26, 2021 at 10:00 AM Andrew Schepler via Std-Discussion <
std-discussion_at_[hidden]> wrote:

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

Or, since `std::array` is a contiguous container, just use
`std::to_address(arr.begin())`.

Received on 2021-09-26 10:03:44