unique_ptr is not copyable or copy-assignable, two instances of unique_ptr cannot manage the same object. A non-const unique_ptr can transfer the ownership of the managed object to another unique_ptr. A const std::unique_ptr cannot be transferred, limiting the lifetime of the managed object to the scope in which the pointer was created. When the unique_ptr is destroyed, it disposes of the object through Deleter.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

Existem duas versões do std::unique_ptr:

Original:

There are two versions of std::unique_ptr:

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.