checked_iterator::operator[]
Returns a reference to an element offset from the element addressed by a checked_iterator by a specified number of positions.
reference operator[](
difference_type_Off
) const;
Parameters
- _Off
The offset from the checked_iterator address.
Return Value
The reference to the element offset.
Remarks
For more information, see Checked Iterators.
Example
// checked_iterators_op_diff.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
int main() {
using namespace std;
vector<int> V1;
for (int i = 0; i < 10 ; i++)
V1.push_back(i);
// Declare a difference type for a parameter
stdext::checked_iterator<vector<int> >::difference_type diff = 2;
stdext::checked_iterator< vector<int> > VChkIter(V1, V1.begin());
stdext::checked_iterator<vector<int> >::reference refrpos = VChkIter [diff];
cout << refrpos + 1 << endl;
}
3
Requirements
Header: <iterator>
Namespace: stdext