Why is the std::iterator_traits::iterator_category for pointers not std::contiguous_iterator_tag?

48 Views Asked by At

iterator_traits is specialized for pointers as

namespace std {
  template<class T>
    requires is_object_v<T>
  struct iterator_traits<T*> {
    using iterator_concept  = contiguous_iterator_tag;
    using iterator_category = random_access_iterator_tag;
    using value_type        = remove_cv_t<T>;
    using difference_type   = ptrdiff_t;
    using pointer           = T*;
    using reference         = T&;
  };
}

- [iterator.traits] p5

How come only the iterator_concept but not the iterator_category for pointers is std::contiguous_iterator_tag. To my knowledge, pointers are contiguous iterators in every sense.

Is this an oversight, or is there a practical reason for this?

0

There are 0 best solutions below