"I think I at least learned enough C++ to be able to read other people's code and understand it"
*proceeds to actually look at a C++ code*
Help, what's a unique_ptr? :blobcat_flopdaze:

std::unique_ptr is a smart pointer that owns (is responsible for) and manages another object via a pointer and subsequently disposes of that object when the unique_ptr goes out of scope.

How is this different to just allocating a struct on the stack? And the memory will get de-allocated once you go out of scope?

Follow

@vaporeon_ my understanding is that you use it if you want an object with heap-allocated memory storage but with the allocation behavior you would expect as if it were on the stack. i do not know why you would want this

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.