raw_storage_iterator::operator=
未保存の反復子式 i = x をメモリに格納するために使用する代入演算子です。
raw_storage_iterator<ForwardIterator, Type>& operator=(
const Type& _Val
);
パラメーター
- _Val
メモリに挿入する型 [種類] のオブジェクトの値。
戻り値
演算子はメモリに _Val を挿入し、生のストレージの反復子への参照を返します。
解説
ForwardIterator の要件は、未保存の反復子が必要な式の *ii = t でのみ有効満たされている必要があること、および operator か operator= に関して何も、単独で言わないことを示します。戻り値の *thisこれらのメンバー演算子。
代入演算子は、格納されている反復子の値を使用して配置の新しい式 new (void (*) &*first) [種類]_Val () を評価して、出力シーケンスで次のオブジェクトを、まず構築します。
使用例
// raw_storage_iterator_op_assign.cpp
// compile with: /EHsc
#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 << "Not constructed.\n";
cout << "Copying " << i << endl; x = i;
return *this;
};
int x;
private:
bool bIsConstructed;
};
int main( void )
{
Int *pInt = ( Int* )malloc( sizeof( Int ) );
memset( pInt, 0, sizeof( Int ) ); // Set bIsConstructed to false;
*pInt = 5;
raw_storage_iterator<Int*, Int> it( pInt );
*it = 5;
}
必要条件
ヘッダー : <memory>
名前空間: std