std::auto_ptr<T>::operator auto_ptr<Y>_C++中文网
| template< class Y > |
(1) | (C++11 中弃用) (C++17 中移除) |
| template< class Y > |
(2) | (C++11 中弃用) (C++17 中移除) |
转换 *this 为对于相异类型 Y 的 auto_ptr 。
1) 返回保有到 *this 引用的实现定义类型对象。 std::auto_ptr 可转换并且可赋值自此模板。允许实现以不同的名称提供该模板,或以其他方式实现等价的功能。
2) 以调用 release() 获得的指针构造新的 auto_ptr 。
参数
(无)
返回值
1) 保有到 *this 的引用的实现定义类型对象。
注意
源自 auto_ptr_ref 的构造函数和复制赋值运算符允许从无名临时量复制构造和赋值 std::auto_ptr 。因为其复制构造函数与复制赋值运算符以非 const 引用接收参数,它们不能直接绑定右值。然而能执行用户定义转换(释放原 auto_ptr ),之后再调用以值接收 auto_ptr_ref 的构造函数或复制赋值运算符。这是移动语义的早期实现。