次の方法で共有


make_checked_array_iterator

他のアルゴリズムで使用できる checked_array_iterator を作成します。

template <class _Iter>
checked_array_iterator<_Iter> make_checked_array_iterator(
    _Iter _Ptr,
    size_t _Size
;)

パラメーター

  • _Ptr
    コピー先の配列へのポインター。

  • _Size
    コピー先の配列のサイズ。

戻り値

checked_array_iterator のインスタンス。

解説

この関数は stdext の名前空間で定義されます。

詳細については、「チェックを行う反復子」を参照してください。

使用例

この例では、[ベクタ] は 10 の項目に作成され、データが設定されます。ベクターの内容は make_checked_array_iterator をコピーしてアルゴリズムを使用して配列に、配置先を指定するにコピーします。

// 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;
}
  

必要条件

ヘッダー: <algorithm>

名前空間: の stdext

参照

関連項目

標準テンプレート ライブラリ