12.1.5. unique_ptr
A unique_ptr
“owns” the object to which it points. Unlike shared_ptr
, only one unique_ptr
at a time can point to a given object. The object to which a unique_ptr
points is destroyed when the unique_ptr
is destroyed. Table 12.4 lists the operations specific to unique_ptr
s. The operations common to both were covered in Table 12.1 (p. 452).
Unlike shared_ptr
, there is no library function comparable to make_shared
that returns a unique_ptr
. Instead, when we define ...
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.