Philipp Henkel wrote:
The encapsulation seems to be perfect in most cases. Unfortunately I've to cope with some legacy (template) code for CComPtrs which relies on operator&. :-/ That's why I tried to provide it for intrusive_ptr. Is there a problem beside the void cast with my operator or its implementation?
The problem with operator& for a smart pointer is that the smart pointer can already have a value. When you hand the address of its raw pointer to QueryInterface, it will overwrite its old value without calling Release() on it. You can guard against that by always zeroing the pointer in operator&, but this leads to a different problem; the expression &x will set x to zero, something that isn't expected or intuitive. Operator& is evil. :-)