首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::auto_ptr::auto_ptr

explicit auto_ptr( X* p = 0 );

(1)

(deprecated)

auto_ptr( auto_ptr& r );

(2)

(deprecated)

template< class Y > auto_ptr( auto_ptr<Y>& r );

(3)

(deprecated)

template< class Y > auto_ptr( auto_ptr_ref<Y> m );

(4)

(deprecated)

构造auto_ptr引用要管理的对象的指针。

1%29构造auto_ptr带指针p...

2%29构造auto_ptr指针在r...r.release()调用以获取对象的所有权。

3%29与%282%29相同。Y*必须隐式转换为T*...

4%29构造auto_ptr中的指针。auto_ptr引用的实例m...p.release()被调用为auto_ptr pm持有以获得物体的所有权。

auto_ptr_ref是包含对auto_ptr...std::auto_ptr隐式可转换到和可从这种类型的。该实现允许为模板提供不同的名称或以其他方式实现等效功能。

参数

p

-

a pointer to an object to manage

r

-

another auto_ptr to transfer the ownership of the object from

m

-

an implementation-defined type that holds a reference to auto_ptr

例外

%280%29

注记

构造函数和复制赋值操作符auto_ptr_ref,以便允许复制构造和赋值。std::auto_ptr来自无名的临时人员。由于它的复制构造函数和复制赋值操作符将参数作为非Const引用,因此它们不能直接绑定rvalue参数。然而,用户定义转换可以执行%28,这将释放原始的自动[医]ptr%29,然后调用构造函数或复制赋值操作符auto_ptr_ref按价值计算。这是对移动语义...

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com