Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining


Assigns one allocator object to another allocator object.

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


An allocator object to be assigned to another such object.

A reference to the allocator object

The template assignment operator does nothing. In general, however, an allocator object assigned to another allocator object should compare equal to it and permit intermixing of object allocation and freeing between the two allocator objects.

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

using namespace std;

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

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

Header: <memory>

Namespace: std

© 2015 Microsoft