background preloader

Smart pointer

Facebook Twitter

Unique_ptr Class. C++ - Differences between unique_ptr and shared_ptr. C++ - Bad practice to return unique_ptr for raw pointer like ownership semantics. Smart pointer. In computer science, a smart pointer is an abstract data type that simulates a pointer while providing additional features, such as automatic memory management or bounds checking .

Smart pointer

These additional features are intended to reduce bugs caused by the misuse of pointers while retaining efficiency. Smart pointers typically keep track of the memory they point to. They may also be used to manage other resources, such as network connections and file handles. Misuse of pointers is a major source of bugs.