std::auto_ptr<T>::operator auto_ptr<Y>
来自cppreference.com
工具库
动态内存管理
|
std::auto_ptr
成员函数 | ||||
auto_ptr::operator
auto_ptr<Y>auto_ptr::operator
auto_ptr_ref<Y>
|
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 为对于相异类型
Y
的 auto_ptr
。
参数
(无)
返回值
1) 保有到 *this
的引用的实现定义类型对象。
注意
源自 auto_ptr_ref
的构造函数和复制赋值运算符允许从无名临时量复制构造和赋值 std::auto_ptr
。因为其复制构造函数与复制赋值运算符以非 const 引用接收参数,它们不能直接绑定右值。然而能执行用户定义转换(释放原
auto_ptr
),之后再调用以值接收 auto_ptr_ref
的构造函数或复制赋值运算符。这是移动语义的早期实现。