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.
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)).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With