std::auto_ptr<T>::operator auto_ptr<Y>

< cpp‎ | memory‎ | auto ptr
 
 
工具库
通用工具
日期和时间
函数对象
格式化库 (C++20)
(C++11)
关系运算符 (C++20 中弃用)
整数比较函数
(C++20)
swap 与类型运算
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
常用词汇类型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等字符串转换
(C++17)
(C++17)
 
动态内存管理
智能指针
(C++11)
(C++11)
(C++11)
(C++17 前)
(C++11)
分配器
内存资源
未初始化存储
未初始化内存算法
有制约的未初始化内存算法
垃圾收集支持
杂项
(C++20)
(C++11)
(C++11)
C 库
低层内存管理
 
 
template< class Y >
operator auto_ptr_ref<Y>() throw();
(1) (C++11 中弃用)
(C++17 中移除)
template< class Y >
operator auto_ptr<Y>() throw();
(2) (C++11 中弃用)
(C++17 中移除)

转换 *this 为对于相异类型 Yauto_ptr

1) 返回保有到 *this 引用的实现定义类型对象。 std::auto_ptr 可转换并且可赋值自此模板。允许实现以不同的名称提供该模板,或以其他方式实现等价的功能。
2) 以调用 release() 获得的指针构造新的 auto_ptr

参数

(无)

返回值

1) 保有到 *this 的引用的实现定义类型对象。
2) 拥有由调用 release() 获得的指针的 auto_ptr

注意

源自 auto_ptr_ref 的构造函数和复制赋值运算符允许从无名临时量复制构造和赋值 std::auto_ptr 。因为其复制构造函数与复制赋值运算符以非 const 引用接收参数,它们不能直接绑定右值。然而能执行用户定义转换(释放原 auto_ptr ),之后再调用以值接收 auto_ptr_ref 的构造函数或复制赋值运算符。这是移动语义的早期实现。