Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-07-27 08:16:37

From: "Philippe A. Bouchard" <philippeb_at_[hidden]>
> Here is an example of an instanciation statement for those who cannot read
> attachments:
> squad_ptr<parent> p(new (ref) child("John", "McInnis"));
> Is it acceptable (the names are temporary)?

Depends. There is a school of thought that will not like it, as it is too
easy to forget the (ref). My personal opinion is that it is acceptable,
provided that there are significant benefits that come from using this form.

But, are you sure that your implementation is correct (strict C++ sense)? In
particular, does the above work when child uses multiple inheritance? Keep
in mind that even when child inherits only from parent, a child*
reinterpret-casted to parent* is not guaranteed to yield the correct pointer
to the parent subobject; multiple inheritance makes this obvious.

Have you tried another compiler? Your implementation looks quite
nonportable, at least at first glance.

Boost list run by bdawes at, gregod at, cpdaniel at, john at