std::auto_ptr<T>:: operator auto_ptr<Y>
From cppreference.net
C++
Memory management library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::auto_ptr
| Member functions | ||||
|
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引用接收,它们无法直接绑定右值参数。但可以执行用户定义的转换
(1)
或
(2)
(这会释放原始
auto_ptr
),随后调用通过值接收
auto_ptr_ref
的构造函数或复制赋值运算符。这是
移动语义
的早期实现。