🇨🇦 Kyle Halladay
Follow

I feel like the presence of a shared pointer as part of a class' member variables should be a compile time failure.

@khalladay What's the alternative for these cases? weak_ptr?

I never know when people are anti shared_ptr due to it's implementation or the broader pattern of a bit of reference counted data living in multiple lifetimes of a library/program.

@photex I'm a big fan of weak pointer. Or alternatively, unique_ptrs for ownership and bare pointers for observing if there's a good argument against weak_ptr.

I think the problem with shared pointers is how easy it is for a code base to fall into the trap of leaning on them too much, and ending up as a total mess.

In my experience, 90% of the time a class member is a shared pointer, it indicates a larger architectural problem.

Sign in to participate in the conversation
Gamedev Mastodon

Game development! Discussions about game development and related fields, and/or by game developers and related professions.