Hans Dembinski wrote:
Looking into boost, I found that the lockfree library has a tagged pointer implementation in its "detail" namespace.
Wouldn't it make sense to make the tagged pointer accessible by users, i.e. place it in a separate library (or in the existing smart_ptr library)?
One issue with tagged pointers is that you need to get it right on every architecture that you care about. An advantage of Boost offering it, rather than everyone implementing their own version, would be that the architecture-specific research would only need to be done once. For example, Facebook's implementation assumes that the top 16 bits of a 64-bit pointer are free. On arm64, as I understand it only the top 8 bits are guaranteed to be free; see e.g. https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt . Boost.Lockfree also uses 16 bits, but it does check for x86_64 first. There is also the question of what happens when you dereference a tagged pointer. Arm64 Linux promises to ignore the tag bits when dereferencing, so no masking is needed (*); on other arm64 operating systems this might not happen so you would need to mask. (*) You can't pass a pointer with tag bits to a system call though. Anyway, yes, it would be great to have this as a public part of Boost. Cheers, Phil.