All Smart Pointers and Ownership Types
All Smart Pointers and Ownership Types
A compact index of ownership, observing, and lifetime-adjacent utility types in modern C++.
All Smart Pointers and Ownership Types
A compact index of ownership, observing, and lifetime-adjacent utility types in modern C++.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
This page focuses on ownership vocabulary rather than every allocator detail.
std::unique_ptr<T>std::unique_ptr<T[]>std::default_delete<T>std::default_delete<T[]>std::shared_ptr<T>std::weak_ptr<T>std::enable_shared_from_this<T>std::make_uniquestd::make_unique_for_overwritestd::make_sharedstd::allocate_sharedstd::make_shared_for_overwritestd::allocate_shared_for_overwritestd::static_pointer_caststd::dynamic_pointer_caststd::const_pointer_caststd::reinterpret_pointer_castT*T& and const T&std::observer_ptr<T> is not in the standard librarystd::span<T> for non-owning contiguous rangesstd::string_view for non-owning string-like rangesstd::reference_wrapper<T> for copyable reference semanticsstd::allocator<T>std::pmr::polymorphic_allocator<T>std::pmr::memory_resourcestd::owner_less<T>std::to_addressstd::unique_ptr by default when one owner is enough.std::shared_ptr only when lifetime is truly shared.std::weak_ptr to break cycles and to observe shared ownership safely.std::span, and std::string_view for non-owning access.#include <memory>
int main() {
auto owner = std::make_unique<int>(42);
auto shared = std::make_shared<int>(*owner);
owner.reset();
return *shared;
}