Earlier quoted context omitted.
No, I don't think it's a joke. It's just that when your counter is limited to values of 0 and 1 only, you can optimize it so heavily it almost looks like a different thing entirely: binary semaphores are usually called mutexes, but they're still semaphores.
Please show me the counter in std::unique_ptr :-)
Retiring a favourite C++ joke
131–140 of 151 posts
Re: Retiring a favourite C++ joke
#132Re: Retiring a favourite C++ joke
#133It's an OK C++ joke, but not great. I could certainly give the author a few pointers...
Re: Retiring a favourite C++ joke
#134Earlier quoted context omitted.
Please show me the counter in std::unique_ptr :-)
Since that counter can only have two values, it's storage is optimized and merged with the underlying raw pointer itself (not unlike Rust's null pointer optimization for enums): non-null value of the underlying pointer also serve to represent the counter's value of 1, and the null value serves to represent the counter's value of 0. The check to not under-decrement, for example, manifests as the null check before call…
Re: Retiring a favourite C++ joke
#135Re: Retiring a favourite C++ joke
#136Earlier quoted context omitted.
That’s called whataboutism.
Nope, it is called experience with large code and teams.
Re: Retiring a favourite C++ joke
#137Earlier quoted context omitted.
I frequently work with companies that have old, large codebases. A key requirement of the training in that environment is that attendees are able to read existing production code. In some cases that's over twenty years old and millions of lines of code. new/delete is just part of that reality. We teach them without encouraging their use.
That's perfectly reasonable. I have fortunately worked on greenfield projects, so don't have to contend with legacy paradigms.
Re: Retiring a favourite C++ joke
#138We are all getting old. College age kids aren't old enough to remember when that show was on the air.
Re: Retiring a favourite C++ joke
#139We are all getting old. College age kids aren't old enough to remember when that show was on the air.
I am also 29 and I'm old enough to remember Dawson's Creek, but I don't watch a lot of TV so I've never seen it.
Re: Retiring a favourite C++ joke
#140There's dozens of people who would get it... DOZENS!
yes, I would have thought the "better" version would be int tobias[24]; delete tobias;