this post was submitted on 30 Nov 2023
-2 points (40.0% liked)

C++

1732 readers
3 users here now

The center for all discussion and news regarding C++.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 1 year ago

You need to know what it does and what it doesn’t or you’ll be surprised.

I don't think that std::unique_ptr is shrouded in mystery: it's designed to be the unique handle of a raw pointer, and it frees the memory when it's lifetime ends. As it's designed to be the unique holder of a resource, it's implemented to disallow making copies. It might be implemented in clever ways, but a developer experience point of view it's quite straight to the point.