In boost C++, a weak pointer is implemented as an observer to a shared (reference counted) pointer.
How are they implemented in objective-c, and why does this require runtime support? (ie besides having compiler support, iOS 5 or above is required to use weak references)
std::weak_ptr actually contains a pointer to a shared data-structure that holds book-keeping data and the referenced object. When the referenced object is destroyed this shared data is kept around so that weak_ptrs can see the book-keeping data that indicates the object is gone, and the weak_ptrs themselves don’t have to be modified when the referenced object is deallocated.
In Objective-C weak references do not point to some intermediate object that holds book-keeping data. They are normal pointers that point either to the actual referenced object, or to nil if the referenced object is gone. Every __weak pointer has to be updated when some other part of the code releases the last non-weak pointer to an object. This requires runtime support.
In other words, Obj-C weak pointers are normal pointers except that there’s compiler magic (which uses runtime support) working on them, whereas shared_ptrs and weak_ptrs are just wrappers that implement their own runtime support (in the smart pointers’ constructors, assignment operators, destructors, etc.) around pointers.