Gregory Colvin wrote: [...]
>> Let's say: >> - you can easily detect weither an object was allocated on the stack >> or on >> the heap; >> - a smart pointer contained within an object can somehow access it's >> "object >> header" when the object was allocated on the heap with a placement >> operator >> new(); > > Neither of which can be done portably. ... "portably" and _efficiently_ ... exactly. But the possibility is still there. Let's say the placement operator new is using malloc(), then we could do some reverse lookup into mallinfo to find the heap block in which some address is related to. This information could then be cached into the smart pointer itself making sizeof(smart_pointer) == (sizeof(void *) * 2) [if shifted_ptr<> style is to be used]: template <typename T> struct smart_pointer { ... private: T * _p; entity_header * _q; }; That would be quite fast, even for the reverse lookup at construction time. The access time would still be atomic. Philippe _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost