I am working on someone else code at work (Qt Desktop application) and found this:
connect( &*mpMainWin, SIGNAL(whatever()), this, SLOT(whatever()) ));
I have some difficulties to understand the part &*mpMainWin. As far as I know about pointers, it returns the address of the de-referenced pointer mpMainWin.
But mpMainWin already hold that address, so giving it directly as a parameter should have the same result.
So if I’m not missing anything and my logic is right, what is the reason of doing such a thing? and if there is one when should we use that kind of syntax?
This can be used as a trick to convert a smart pointer (i.e. not really a pointer, a class implementing
operator*()) into a plain pointer. Without seeing howmpMainWinis declared it is impossible to say if that’s the case here. IfmpMainWinis a plain pointer to begin with then yes,&*mpMainWinis the same as justmpMainWin.