All Smart-Pointer Operations
All Smart-Pointer Operations
A compact scan page for creation, ownership queries, casts, resets, and observer operations on standard smart pointers.
All Smart-Pointer Operations
A compact scan page for creation, ownership queries, casts, resets, and observer operations on standard smart pointers.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
std::make_uniquestd::make_unique_for_overwritereleaseresetgetswapstd::make_sharedstd::make_shared_for_overwritestd::allocate_sharedstd::allocate_shared_for_overwriteuse_countuniqueresetswaplockexpireduse_countresetowner_beforestd::static_pointer_caststd::dynamic_pointer_caststd::const_pointer_caststd::reinterpret_pointer_castmake_unique and make_shared over naked new at call sites.use_count() as observational, not as a synchronization primitive.weak_ptr::lock() to safely obtain temporary shared ownership.#include <memory>
int main() {
auto owner = std::make_unique<int>(42);
auto shared = std::make_shared<int>(*owner);
owner.reset();
return *shared;
}