Le 19/11/11 13:45, Peter Dimov a écrit :
You are right. There is no way to distinguish a stack-allocated Object from another stack-allocated Object created at the same address, so a map keyed by the object address can't work. Your other option may be unique per-object identifiers for use as keys, with ~Object somehow marking the identifier as invalid. But the "invalid identifier" set will soon grow out of hand and I'm not seeing a way to purge it. You could, perhaps, store a shared_ptr to a dummy identifier object and use the corresponding weak_ptr as a key, but I'm not sure that this is worth the trouble (and allocations) if stack use is rare.
Hi, I don't see why the thread_specific_ptr could not store a key that will be managed by the pthread_key_ functions. AM I missing something evident; isn't it? Best, Vicente