allocator::operator =

指派給其他配置器物件的配置器物件。

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

參數

  • _Right
    將指定的配置器物件加入另一個這類物件。

傳回值

在配置器物件的參考。

備註

範本指派運算子不會有任何作用。不過,一般而言,配置器物件指派給其他配置器物件應該相等並允許混合物件配置和釋放在兩個配置器物件之間。

範例

// 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 Class