raw_storage_iterator::raw_storage_iterator
지정 된 기본 출력 반복기를 사용 하는 원시 스토리지 반복기를 만듭니다.
explicit raw_storage_iterator(
ForwardIterator _First
);
매개 변수
- _First
기초가 되는 정방향 반복기는 raw_storage_iterator 생성 중인 개체입니다.
예제
// raw_storage_iterator_ctor.cpp
// compile with: /EHsc /W3
#include <iostream>
#include <iterator>
#include <memory>
#include <list>
using namespace std;
class Int
{
public:
Int(int i)
{
cout << "Constructing " << i << endl;
x = i;
bIsConstructed = true;
};
Int &operator=( int i )
{
if (!bIsConstructed)
cout << "Error! I'm not constructed!\n";
cout << "Copying " << i << endl; x = i; return *this;
};
int x;
bool bIsConstructed;
};
int main( void )
{
std::list<int> l;
l.push_back( 1 );
l.push_back( 2 );
l.push_back( 3 );
l.push_back( 4 );
Int *pInt = (Int*)malloc(sizeof(Int)*l.size( ));
memset (pInt, 0, sizeof(Int)*l.size( ));
// Hack: make sure bIsConstructed is false
std::copy( l.begin( ), l.end( ), pInt ); // C4996
for (unsigned int i = 0; i < l.size( ); i++)
cout << "array " << i << " = " << pInt[i].x << endl;;
memset (pInt, 0, sizeof(Int)*l.size( ));
// hack: make sure bIsConstructed is false
std::copy( l.begin( ), l.end( ),
std::raw_storage_iterator<Int*,Int>(pInt)); // C4996
for (unsigned int i = 0; i < l.size( ); i++ )
cout << "array " << i << " = " << pInt[i].x << endl;
free(pInt);
}
요구 사항
헤더: <memory>
네임 스페이스: std