Freigeben über


operator== (<memory>)

Tests for equality between allocator objects of a specified class.

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

Parameters

  • _Left
    One of the allocator objects to be tested for equality.

  • _Right
    One of the allocator objects to be tested for equality.

Return Value

true if the allocator objects are equal; false if allocator objects are not equal.

Remarks

Two allocator objects should compare equal only if an object allocated through one can be deallocated through the other. If the value of one object is determined from another by assignment or by construction, the two objects should compare equal.

Example

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

using namespace std;

int main( ) 
{
   allocator<char> Alloc;
   vector <int>:: allocator_type v1Alloc;

   allocator<char> cAlloc(Alloc); 
   allocator<int> cv1Alloc(v1Alloc);

   if ( cv1Alloc == v1Alloc )
      cout << "The allocator objects cv1Alloc & v1Alloc are equal."
           << endl;
   else
      cout << "The allocator objects cv1Alloc & v1Alloc are not equal."
           << endl;

   if ( cAlloc == Alloc )
      cout << "The allocator objects cAlloc & Alloc are equal."
           << endl;
   else
      cout << "The allocator objects cAlloc & Alloc are not equal."
           << endl;
}

The allocator objects cv1Alloc & v1Alloc are equal.
The allocator objects cAlloc & Alloc are equal.

Requirements

Header: <memory>

Namespace: std

See Also

Concepts

auto_ptr Class

auto_ptr Members