๐Ÿ‡จ๐Ÿ‡ฆ Kyle Halladay is a user on mastodon.gamedev.place. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
๐Ÿ‡จ๐Ÿ‡ฆ Kyle Halladay @khalladay

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

ยท 0 ยท 0

@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.