Boost logo

Boost :

Subject: Re: [boost] interest in a stateful pointer library?
From: Peter Dimov (lists_at_[hidden])
Date: 2017-10-09 15:54:01


Hans Dembinski wrote:

> Ok, yes, but tripping an assert (or raising a compile-time error) on an
> unsupported platform is not a nice solution, I think. Wouldn't it be
> better to provide a fallback that at least works somehow without crashing
> build or runtime?

Once you encounter the platform where it doesn't work, you'll have to
provide a fallback, yes. Before that, not.

> auto d = new Derived(); // inherits from Base with virtual dtor
> auto b = static_cast<Base*>(d); // still the same physical address, so
> should map to the same integer, no?

No. It's neither the same physical address in general, nor is it required to
map to the same integer even if it were.

> delete b; // correctly deletes Derived using vtable

If Base has a vtable, yes. You're not asserting that though.

> I made tagged_ptr mimic std::unique_ptr, because I rely on having full
> control over (de)allocation to harvest the low bits of the pointer.

tagged_unique_ptr then perhaps?


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