次の方法で共有


raw_storage_iterator::operator*

未保存の反復子式の *ii = x を実行するために使用する逆参照する演算子。

raw_storage_iterator<ForwardIterator, Type>& operator*( );

戻り値

未保存の反復子への参照

解説

ForwardIterator の要件は、未保存の反復子が必要な式の *ii = t でのみ有効満たされている必要があること、および operatoroperator= に関して何も、単独で言わないことです。この実装のメンバー演算子は operator=(constType&) が式で実際のストアを実行できるように *_Ptr = _Valなどの *thisを返します。

使用例

// raw_storage_iterator_op_deref.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

参照

関連項目

raw_storage_iterator Class