Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-08-21 19:14:24


"Larry Evans" <jcampbell3_at_[hidden]> wrote:

[...]

> >"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote:
> >It seems 3 specific types of hierarchies have be isolated:
> >struct simple_hierarchy {};
> >struct complex_hierarchy {};
> >struct ambiguous_hierarchy {}.
> >
> >What about 3 adjacent ptr_base<> types:
> >ptr_base<T, simple_hierarchy>;
> >ptr_base<T, complex_hierarchy>;
> >ptr_base<T, ambiguous_hierarchy>.
> >
> >Which will have the following properties:
> >sizeof(ptr_base<T, simple_hierarchy>) = sizeof(T *);
> >sizeof(ptr_base<T, complex_hierarchy>) = sizeof(T *);
> >sizeof(ptr_base<T, ambiguous_hierarchy>) = sizeof(int *) + sizeof(T *).
> >
> >ambiguous_hierarchy could be the default one. Others would be
> >optimizations.
> >
> >
> >
> Agreed. It would be nice if the compiler could determine which
> type of heirarchy :(.

I know...

> BTW, the object contributing the sizeof(int*) term would just point to
> the reference count? Or would it point to both the reference count +
> the object, in order to just use one allocation?

int * will stick to the beginning of reference count + object and will be
used for deallocation at the same time:

m_count <- m_hdr (int * or ptr_header *)
m_typeid
ambiguous type <~ ...
ambiguous child <~ m_ptr (T *)
ambiguous child <~ ...

Conversions between those pointer types could be added at a certain degree
also.

Philippe A. Bouchard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk