在文件“内存”中的·std::unique_ptr·代码中,我看到运算符重载函数为
typename tr1::add_reference<_Ty>::type operator*() const
{
// return reference to object
return (*this->_Myptr);
}
pointer operator->() const
{
// return pointer to class object
return (&**this);
}
第二个函数中的&**
是什么意思?谢谢。
最佳答案
this
是指向 unique_ptr
对象的指针。
*this
是对 unique_ptr
对象的引用。
**this
使用 operator*
(即 *this->_Myptr
)取消引用 unique_ptr
。
因此,&**this
是指向对象的指针,该对象由 unique_ptr
(即 &(*this->_Myptr)
).
关于c++ - 这是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15044874/