this post was submitted on 30 Nov 2023
-1 points (45.5% liked)

C++

1763 readers
1 users here now

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

Rules

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 11 months 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.