Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-09-03 14:08:54


Philippe A. Bouchard wrote:
[snip]

>What about implementing some exception when get_count() == 2. Given:
>
There could be 2 placed_ptr's on stack pointing to the same referent.

>bool is_on_data(void * p); // Confirm p is address on data segment
>bool is_on_stack(void * p); // Confirm p is address on stack segment
>bool is_on_heap(void * p); // Confirm p is address on heap segment
>
The above would be os dependent. I don't think that's much of a problem
since
all the conservative methods used os dependent methods to delimit the
stack and
data segments. I'm guessing that a data segment is where static data is
stored?

>
>struct placed_ptr_header
>{
> int m_count;
> void * m_owner; // Could point to stacked candidate for destruction
>};
>
>placed_ptr<T>::placed_ptr(...)
>{
> if (is_on_stack(this))
>
should ^ also have "|| is_on_data(this)"?

> {
> get_owner() = this;
> }
> ...
>}
>
>placed_ptr<T>::~placed_ptr()
>{
> if (m_ptr)
> {
> -- get_count();
>
> if (get_count() == 0)
> {
> m_ptr->~T();
> free(m_ptr - ...);
> }
> else if (get_count() == 1 && get_owner() == this)
>
What if remainng placed_ptr is ALSO on stack?


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