make_checked_array_iterator
Creates a checked_array_iterator that can be used by other algorithms.
template <class _Iter>
checked_array_iterator<_Iter> make_checked_array_iterator(
_Iter _Ptr,
size_t _Size
;)
Parameters
_Ptr
A pointer to the destination array._Size
The size of the destination array.
Return Value
An instance of checked_array_iterator.
Remarks
This function is defined in the stdext namespace.
For more information, see Checked Iterators.
Example
In this example, a vector is created and populated with 10 items. The contents of the vector are copied into an array using the copy algorithm, using make_checked_array_iterator to specify the destination.
// make_checked_array_iterator.cpp
// compile with: /EHsc
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
const size_t dest_size = 10;
int *dest = new int[dest_size];
vector<int> v;
for (int i = 0; i < 10; i++)
{
v.push_back(i);
}
copy(v.begin(), v.end(), stdext::make_checked_array_iterator(dest, dest_size));
for (int i = 0; i < dest_size; i++)
{
cout << dest[i] << endl;
}
delete[] dest;
}
0
1
2
3
4
5
6
7
8
9
Requirements
Header: <algorithm>
Namespace: stdext