Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C++ devs can get creative with their responsibility patterns. My personal favourite so far (found in a friend's project) is the "weak referent" pattern which is an object that refers to some other objects passively but strongly, meaning that it can not affect them in any way but it also must be finalized before them. The result is a twisted backwards logic on the external interface such that the weak referent's lifetime ends when any of its referents' lifetimes end.
Weak referents don't give out weak references to themselves. A weak referent is an object in memory that will be freed when any of some other objects are freed. The referrer is responsible for keeping track of each of those lifetimes. After that point, they're holding an invalid object which generally doesn't have a validity flag. -
This is actually the same as a struct with a reference field in Rust, but without the borrow checker it's the biggest footgun programmer has ever written.
-
Most "creative" solutions in C++ are bad solutions, alas, that's the power you command when the language doesn't try to restrict you.
What your friend tried to do is solved with correct use of shared_ptr and weak_ptr (or their boost versions if dealing with c++03). -
@LotsOfCaffeine It's some weird windows UWP C#/C++ library built on top of idl description files 🙃
-
@12bitfloat
Ugh, hope you are not talking about that abomination that is C++/CLR.
If so, my condolences.
Related Rants
-
cdrice105"You gave us bad code! We ran it and now production is DOWN! Join this bridgeline now and help us fix this!" ...
-
MoboTheHobo36My Friend: Dude our Linux Server is not working anymore! Me: What? What did you do? My friend: Nothing I swe...
-
tommy15Right now someone at Google is coding something useless for us to laugh at on April Fools.
Oh boy I have to interact with some C++ library code again, please kill me now
rant
cpp
rust
fml