[simd.iterator]

# 29 Numerics library [[numerics]](./#numerics)

## 29.10 Data-parallel types [[simd]](simd#iterator)

### 29.10.6 Class template *simd-iterator* [simd.iterator]

[ð](#lib:iterator,basic_vec)

namespace std::simd {template<class V>class *simd-iterator* { // *exposition only* V* *data_* = nullptr; // *exposition only**simd-size-type* *offset_* = 0; // *exposition only*constexpr *simd-iterator*(V& d, *simd-size-type* off) noexcept; // *exposition only*public:using value_type = typename V::value_type; using iterator_category = input_iterator_tag; using iterator_concept = random_access_iterator_tag; using difference_type = *simd-size-type*; constexpr *simd-iterator*() = default; constexpr *simd-iterator*(const *simd-iterator*&) = default; constexpr *simd-iterator*& operator=(const *simd-iterator*&) = default; constexpr *simd-iterator*(const *simd-iterator*<remove_const_t<V>>&) requires is_const_v<V>; constexpr value_type operator*() const; constexpr *simd-iterator*& operator++(); constexpr *simd-iterator* operator++(int); constexpr *simd-iterator*& operator--(); constexpr *simd-iterator* operator--(int); constexpr *simd-iterator*& operator+=(difference_type n); constexpr *simd-iterator*& operator-=(difference_type n); constexpr value_type operator[](difference_type n) const; friend constexpr bool operator==(*simd-iterator* a, *simd-iterator* b) = default; friend constexpr bool operator==(*simd-iterator* a, default_sentinel_t) noexcept; friend constexpr auto operator<=>(*simd-iterator* a, *simd-iterator* b); friend constexpr *simd-iterator* operator+(*simd-iterator* i, difference_type n); friend constexpr *simd-iterator* operator+(difference_type n, *simd-iterator* i); friend constexpr *simd-iterator* operator-(*simd-iterator* i, difference_type n); friend constexpr difference_type operator-(*simd-iterator* a, *simd-iterator* b); friend constexpr difference_type operator-(*simd-iterator* i, default_sentinel_t) noexcept; friend constexpr difference_type operator-(default_sentinel_t, *simd-iterator* i) noexcept; };}

[ð](#itemdecl:1)

`constexpr simd-iterator(V& d, simd-size-type off) noexcept;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17346)

*Effects*: Initializes *data_* with addressof(d) and *offset_* with off[.](#1.sentence-1)

[ð](#itemdecl:2)

`constexpr simd-iterator(const simd-iterator<remove_const_t<V>>& i) requires is_const_v<V>;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17356)

*Effects*: Initializes *data_* with i.*data_* and *offset_* with i.*offset_*[.](#2.sentence-1)

[ð](#itemdecl:3)

`constexpr value_type operator*() const;
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17366)

*Effects*: Equivalent to: return (**data_*)[*offset_*];

[ð](#itemdecl:4)

`constexpr simd-iterator& operator++();
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17376)

*Effects*: Equivalent to: return *this += 1;

[ð](#itemdecl:5)

`constexpr simd-iterator operator++(int);
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17386)

*Effects*: Equivalent to:*simd-iterator* tmp = *this;*this += 1;return tmp;

[ð](#itemdecl:6)

`constexpr simd-iterator& operator--();
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17401)

*Effects*: Equivalent to: return *this -= 1;

[ð](#itemdecl:7)

`constexpr simd-iterator operator--(int);
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17411)

*Effects*: Equivalent to:*simd-iterator* tmp = *this;*this -= 1;return tmp;

[ð](#itemdecl:8)

`constexpr simd-iterator& operator+=(difference_type n);
`

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17426)

*Preconditions*: *offset_* + n is in the range [0, V​::​size()][.](#8.sentence-1)

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17430)

*Effects*: Equivalent to:*offset_* += n;return *this;

[ð](#itemdecl:9)

`constexpr simd-iterator& operator-=(difference_type n);
`

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17444)

*Preconditions*: *offset_* - n is in the range [0, V​::​size()][.](#10.sentence-1)

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17448)

*Effects*: Equivalent to:*offset_* -= n;return *this;

[ð](#itemdecl:10)

`constexpr value_type operator[](difference_type n) const;
`

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17462)

*Effects*: Equivalent to: return (**data_*)[*offset_* + n];

[ð](#itemdecl:11)

`friend constexpr bool operator==(simd-iterator i, default_sentinel_t) noexcept;
`

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17472)

*Effects*: Equivalent to: return i.*offset_* == V​::​size();

[ð](#itemdecl:12)

`friend constexpr auto operator<=>(simd-iterator a, simd-iterator b);
`

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17482)

*Preconditions*: a.*data_* == b.*data_* is true[.](#14.sentence-1)

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17486)

*Effects*: Equivalent to: return a.*offset_* <=> b.*offset_*;

[ð](#itemdecl:13)

`friend constexpr simd-iterator operator+(simd-iterator i, difference_type n);
friend constexpr simd-iterator operator+(difference_type n, simd-iterator i);
`

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17497)

*Effects*: Equivalent to: return i += n;

[ð](#itemdecl:14)

`friend constexpr simd-iterator operator-(simd-iterator i, difference_type n);
`

[17](#17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17507)

*Effects*: Equivalent to: return i -= n;

[ð](#itemdecl:15)

`friend constexpr difference_type operator-(simd-iterator a, simd-iterator b);
`

[18](#18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17517)

*Preconditions*: a.*data_* == b.*data_* is true[.](#18.sentence-1)

[19](#19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17521)

*Effects*: Equivalent to: return a.*offset_* - b.*offset_*;

[ð](#itemdecl:16)

`friend constexpr difference_type operator-(simd-iterator i, default_sentinel_t) noexcept;
`

[20](#20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17531)

*Effects*: Equivalent to: return i.*offset_* - V​::​size();

[ð](#itemdecl:17)

`friend constexpr difference_type operator-(default_sentinel_t, simd-iterator i) noexcept;
`

[21](#21)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17542)

*Effects*: Equivalent to: return V​::​size() - i.*offset_*;
