allocator::operator=

Weist ein allocator-Objekt zu einem anderen allocator-Objekt zu.

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

Parameter

  • _Right
    Ein zu einem anderen so zugewiesen werden allocator-Objekt, Objekt.

Rückgabewert

Ein Verweis auf allocator-Objekt

Hinweise

Der Vorlagenzuweisungsoperator Auswirkungen.Im Allgemeinen sollte jedoch ein allocator-Objekt, das zu einem anderen allocator-Objekt zugewiesen wird, gleich es vergleichen und das Vermischen der Objektzuordnung und Freigeben zwischen den beiden allocator-Objekten aktivieren.

Beispiel

// 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;    
}

Anforderungen

Header: <memory>

Namespace: std

Siehe auch

Referenz

allocator Class