Boost logo

Boost :

Subject: Re: [boost] interest in a stateful pointer library?
From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2017-10-11 09:11:59

Hi Ion,

> On 11. Oct 2017, at 10:21, Ion Gaztañaga via Boost <boost_at_[hidden]> wrote:
> On 10/10/2017 10:02, Hans Dembinski via Boost wrote:
>> Hi Ion,
>>> On 10. Oct 2017, at 00:17, Ion Gaztañaga via Boost <boost_at_[hidden]> wrote:
>>> There is a related (not a replacement) utility in Boost.Intrusive, used to store additional bits in red-black and AVL trees:
>>> <>
>>> It assumes the conversion between pointers and integers preserves the alignment in the lower bits of the integer. There are some esoteric platforms where this might not be true, but Boost.Intrusive does not support them.
>> ah, thanks, I didn't know that one. I thought Boost.Intrusive was about containers only, so I would never have looked there. Seeing how pointer_plus_bits is used in Boost.Intrusive, it seems that it is not really intended for users, and serves more as an utility for the library. It is not advertised in the documentation either.
> Right now it's used internally and shared with Boost.Interprocess. But obviously we could make them public. The main point is that an utility to embed bits in pointers could consider also fancy pointers.

Yes, you are right. I think that's the way to go.

I am still a bit puzzled how pointer_plus_bits is used in Boost.Intrusive. As far as I can see by reading the code, in boost/intrusive/detail/rbtree_node.hpp and boost/intrusive/detail/avltree_node.hpp it is simply assumed that one or two bits from the pointer can be harvested. There is no platform-check and no general fallback solution. If I used this code on a platform where the assumptions related to bit harvesting are violated, I would trip a BOOST_INTRUSIVE_INVARIANT_ASSERT at runtime instead of crashing, but I could not run the software on such a system.

Which platforms are supported by Boost.Intrusive? Does it work on an ARM processor? The documentation does not say anything about that. That is a bit scary, to be honest. I always assumed that Boost libraries are platform-independent unless explicitly stated otherwise.

Best regards,

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