分配给另一个分配器对象的已分配程序对象。
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