Subj : Re: atomic operations api added to AppCore... To : comp.programming.threads From : awaken Date : Fri Feb 25 2005 09:08 am >I don't think this would compile if AnchorType >doesn't have a >constructor.. yes it have - I ommited it. it's purpose only to initialize this 64bit structure >Are you sure you don't need those two bits of >your pointer? Are you sure >you never forget to mask your pointer so you >take the two bits out and >don't use corrupted pointers - ever? I'm going to use wrapper class instead raw pointers whenever I can, so it will take care about masking/unmasking Of couse it's very hardware specific It may look like this: template class PackedPtr { union { unsigned int dummy_bits:2; unsigned int ptr_:30; }; public: PackedPtr(): ptr_(0){}; PackedPtr(const T& ptr) { ptr_ = reinterpret_cast(&ptr); } PackedPtr(const T* ptr) { ptr_ = reinterpret_cast(ptr); } PackedPtr& operator=(const T& ptr) { ptr_ = reinterpret_cast(ptr); return ptr_; } T* operator->() const { return reinterpret_cast(ptr_); } operator T*() { return (reinterpret_cast(ptr_)); } }; .