这是什么意思?

use*_*020 2 c++ smart-pointers operator-overloading

在·std :: unique_ptr·文件"memory"中的代码中,我将操作符重载函数视为

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);
}
Run Code Online (Sandbox Code Playgroud)

&**第二个函数的意思是什么?谢谢.

nne*_*neo 6

this是指向unique_ptr对象的指针.

*thisunique_ptr对象的引用.

**this正在取消引用unique_ptr使用operator*(即*this->_Myptr).

所以,&**this是指向unique_ptr(ie &(*this->_Myptr))指向的对象的指针.


Naw*_*waz 5

根据发布的代码,**this调用operator*重载返回对象的引用.所以&**this成为返回对象的地址.

换句话说,**this与...相同(*this->_Myptr),并且&**this相同&(*this->_Myptr).