unique_ptr
A unique_ptr is a smart pointer in C++ that manages the lifetime of a dynamically allocated object. It ensures that the object is automatically deleted when the unique_ptr goes out of scope, preventing memory leaks. Unlike regular pointers, a unique_ptr cannot be copied, which means that it maintains sole ownership of the object it points to.
To transfer ownership of the managed object, a unique_ptr can be moved to another unique_ptr using the move semantics. This feature makes unique_ptr a safer alternative to raw pointers, as it enforces clear ownership rules and simplifies memory management in C++ programs.