CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 21 Jul 2025 16:18:00 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/iterator/iterator/
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 21 Jul 2025 16:18:00 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"7f66-fmav+695w/Dw3EHvdZJVhT1sXQQ"
Content-Encoding: gzip
[Note: This page describes the base class std::iterator. For general information about iterators, refer to header]
This is a base class template that can be used to derive iterator classes from it. It is not an iterator class and does not provide any of the functionality an iterator is expected to have.
This base class only provides some member types, which in fact are not required to be present in any iterator type (iterator types have no specific member requirements), but they might be useful, since they define the members needed for the default iterator_traits class template to generate the appropriate instantiation automatically (and such instantiation is required to be valid for all iterator types).
It is defined as:
Output:
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<iterator>
- iterator
- iterator_traits
functions
- advance
- back_inserter
-
beginC++11
- distance
-
endC++11
- front_inserter
- inserter
-
make_move_iteratorC++11
-
nextC++11
-
prevC++11
iterator categories
predefined iterators
- Reference
- <iterator>
- iterator
class template
<iterator>
std::iterator
template <class Category, // iterator::iterator_category class T, // iterator::value_type class Distance = ptrdiff_t, // iterator::difference_type class Pointer = T*, // iterator::pointer class Reference = T& // iterator::reference > class iterator;
Iterator base class
This is a base class template that can be used to derive iterator classes from it. It is not an iterator class and does not provide any of the functionality an iterator is expected to have.
This base class only provides some member types, which in fact are not required to be present in any iterator type (iterator types have no specific member requirements), but they might be useful, since they define the members needed for the default iterator_traits class template to generate the appropriate instantiation automatically (and such instantiation is required to be valid for all iterator types).
It is defined as:
|
|
Template parameters
- Category
- Category to which the iterator belongs to. It must be one of the following iterator tags:
- T
- Type of elements pointed by the iterator.
- Distance
- Type to represent the difference between two iterators.
- Pointer
- Type to represent a pointer to an element pointed by the iterator.
- Reference
- Type to represent a reference to an element pointed by the iterator.
Member types
member type | definition | notes |
---|---|---|
iterator_category | the first template parameter (Category) | |
value_type | the second template parameter (T) | |
difference_type | the third template parameter (Distance) | defaults to: ptrdiff_t |
pointer | the fourth template parameter (Pointer) | defaults to: T* |
reference | the fifth template parameter (Reference) | defaults to: T& |
Example
|
|
Output:
10 20 30 40 50 |
See also
- <iterator>
- Iterator definitions (header)
- iterator_traits
- Iterator traits (class template)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us