Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does &** mean?

In ·std::unique_ptr· code in file "memory", I see operator overloading functions as

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);
}

What does the &** mean in the second function? Thanks.

like image 906
user1899020 Avatar asked Dec 05 '25 05:12

user1899020


1 Answers

this is a pointer to the unique_ptr object.

*this is a reference to the unique_ptr object.

**this is dereferencing the unique_ptr using operator* (i.e. *this->_Myptr).

So, &**this is a pointer to the object pointed at by the unique_ptr (i.e. &(*this->_Myptr)).

like image 149
nneonneo Avatar answered Dec 06 '25 23:12

nneonneo