allocator::operator=
Assigns one allocator object to another allocator object.
template<class Other>
allocator<Type>& operator=(
const allocator<Other>& _Right
);
매개 변수
- _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 {
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