Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement Shared and Weak Ownership Pointers

Model reference-counted resource ownership with copy, move, weak observation, custom cleanup, and safe control-block lifetime.

Design and implement the core of a C++ smart-pointer library. For this exercise, assume SharedOwner<T> provides shared ownership of one heap resource through a control block, WeakOwner<T> observes that control block without extending the resource lifetime, and UniqueOwner<T> owns one resource exclusively.

Support construction, destruction, copy and move operations, reset, use-count inspection, weak lock, and an optional custom deleter. Destroy the resource exactly once when the strong count reaches zero and destroy the control block only after both the resource is gone and no weak observers remain.

Copies of handles may cross threads, so count changes must be safe; access to the managed object itself is not automatically synchronized. Null handles and failed weak locks have explicit behavior.

Array ownership, aliasing constructors, custom allocators, enable-shared-from-this, and full standard-library compatibility are outside scope.