
On 30 Mar 2012, at 14:21, Tim Blechmann wrote:
Wouldn't it make sense to move it into a separate library entirely? It would possibly get more exposure and cross-platform ports. The technique itself also requires some extra documentation. And it might find it's way into a release earlier than lock-free itself.
for now i prefer to keep it an implementation detail. but maybe it can be exposed to the public API in future. how now i'd like to wait until there are some std::atomic implementation which can actually compile the tagged_ptr. i hope boost.lockfree will be in 1.50, still waiting for boost.atomic, though Isn't tagged_ptr also useful even when it is not used atomically?
i've personally not seen any use case for a tagged pointer except for prevention of the ABA problem. especially the pointer-compression is mainly to pack pointer and tag into a 64bit memory region, which is mainly required for systems without 128bit compare-and-swap ...
Tagged pointers are also useful for implementing implementing union-like types. I personally use a variant_ptr type, which on 64-bit systems uses tags to store the type of the variant, rather than requiring an extra int to be allocated in the variant object. Tagged pointers are also useful as a basis for things like the small-string optimisation, storing a value in a pointer. I'm not sure if I would start building such a thing on a tagged pointer however. Perhaps if I already had one to hand. Chris