Great explanation, as someone who is new to C++ and actively learning, these perspectives are invaluable.
I have been using some shared pointers in a personal project because of its ease of use but I aim to review and refactor this code to follow C++ idioms more appropriately. Thank you!
In these cases I usually opt for gsl::not_null<T>
Re:How to make Flappy Bird with C++
by SuperV1234 on Thursday August 25, 2022 @06:21PM
(#32600690)
You don't even need 'unique_ptr'. The render window on its own is completely fine.
As for why - it's mostly around signaling intent and protecting against leaks. It's much easier to reason about ownership if you don't have to worry about some object deep inside your engine hierarchy holding a `shared_ptr` to the object that owns it. This can still happen with unique_ptr, but is much less likely.