Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-01-04 16:11:16


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. :-)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net