C++ Logo


Advanced search

Iterators of the class template std::array

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Sun, 26 Sep 2021 14:27:03 +0300
I have run the program below using gcc 8.3 and its output is true.
#include <iostream>
#include <array>
#include <type_traits>
int main()
    std::cout << std::is_same<std::array<int, 2>::iterator, std::array<int, 5>::iterator>::value
              << '\n';
    return 0;
Though if I am not mistaken there is nothing said in the Standard whether iterators of two instantiations of the class template std::array std::array<T, N1> and std::array <T, N2> have the same types of iterators.
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.
With best regards,
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

Received on 2021-09-26 06:27:13