Udostępnij za pośrednictwem


checked_array_iterator::checked_array_iterator

Constructs a default checked_array_iterator or a checked_array _iterator from an underlying iterator.

checked_array_iterator( );
checked_array_iterator(
   ITerator ptr,
   size_t size,
   size_t index = 0
);

Parameters

  • ptr
    A pointer to the array.

  • size
    The size of the array.

  • index
    (Optional) An element in the array, to initialize the iterator. By default, the iterator is initialized to the first element in the array.

Remarks

For more information, see Checked Iterators.

Example

// checked_array_iterators_ctor.cpp
// compile with: /EHsc
#include <iterator>
#include <iostream> 

using namespace std;
using namespace stdext;

int main() {
   int a[] = {0, 1, 2, 3, 4};
   int b[5];
   copy(a, a + 5, checked_array_iterator<int*>(b,5));

   for (int i = 0 ; i < 5 ; i+)
      cout << b[i] << " ";
   cout << endl;

   checked_array_iterator<int*> checked_output_iterator(b,5);
   copy (a, a + 5, checked_output_iterator);
   for (int i = 0 ; i < 5 ; i+)
      cout << b[i] << " ";
   cout << endl;

   checked_array_iterator<int*> checked_output_iterator2(b,5,3);
   cout << *checked_output_iterator2 << endl;
}

0 1 2 3 4 0 1 2 3 4 3

Requirements

Header: <iterator>

Namespace: stdext

See Also

Reference

checked_array_iterator Class

Standard Template Library

Other Resources

checked_array_iterator Members