Subscribe to EdwinNameless' Fake Blog        RSS Feed

2 Messages of Note

Icon Leave Comment
Had to stick them here, as the capability of the C++ forum to generate piles of crap is unbelievable, and gems like these get lost in the process. Both messages are from Bench who, AFAICT, is probably the most matter-of-fact, no BS expert around here. As said before, I am learning C++ on the side, and his 2 messages taught me more than anything I have learnt from wandering around here for 2 months...

The first one was about a neat little trick to tell whether a class and its subclass are related, and the second one is about pointers, and how one should favour auto_ptr to handle them.

Researching this a bit more, I came across this interesting dialogue about auto_ptr vs. (Boost) shared_ptr soon-to-become-c++-standard-but-wait-a-bit-like-we-are-still-waiting-for-LaTeX3. Some bits are just plain obscure for me, but still, I get the point. This led me to investigate shared_ptr:


A simple guideline that nearly eliminates the possibility of memory leaks is: always use a named smart pointer variable to hold the result of new. Every occurrence of the new keyword in the code should have the form:

shared_ptr<T> p(new Y);

And that's it, that's the talent of the man: 2 well-written posts jam-packed with technical details, enough thread sticking out of the ball, and you end up dragging enough wool out to start knitting a decent pair of socks. Good job, Bench.

0 Comments On This Entry



This is my fake blog. 'Cause I also have a real blog with real stuff in it.

October 2020

252627 28 293031

Recent Entries

Recent Comments

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)