次の方法で共有


allocator::operator=

別のアロケーター オブジェクトへの 1 回のアロケーター オブジェクトを割り当てます。

template<class Other>
   allocator<Type>& operator=(
      const allocator<Other>& _Right
   );

パラメーター

  • _Right
    別の #line hidden に割り当てられているアロケーター オブジェクト。

戻り値

アロケーター オブジェクトへの参照

解説

テンプレートの代入演算子は、何も行いません。 ただし、通常は、別のアロケーター オブジェクトに割り当てられているアロケーター オブジェクトは、に等しい、オブジェクトの割り当てが混在し、2 種類のアロケーター オブジェクト間の解放を許可する必要があります。

使用例

// allocator_op_assign.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
#include <vector>

using namespace std;

class Int {
public:
   Int(int i) 
   {
      cout << "Constructing " << ( void* )this  << endl; 
      x = i;
      bIsConstructed = true;
   };
   ~Int( ) {
      cout << "Destructing " << ( void* )this << endl; 
      bIsConstructed = false;
   };
   Int &operator++( ) 
   {
      x++;
      return *this;
   };
   int x;
private:
   bool bIsConstructed;
};

int main( ) 
{
   allocator<Int> Alloc;
   allocator<Int> cAlloc ;
   cAlloc = Alloc;    
}

必要条件

ヘッダー: <memory>

名前空間: std

参照

関連項目

allocator クラス