Monday, November 18, 2013

FeedaMail: Comments for Sutter̢۪s Mill

feedamail.com Comments for Sutter's Mill

Comment on (V)C++ recorded talks at VS 2013 Launch by nosenseetal

Herb this is offtopic, but regarding memory leak in your fav 10 liner…
seems like a job for:
Boost.CircularBuffer :)

Also I know you probably hate to comment on quality of MS code but do you have opinion is this an ok modern C++ code or it could be done cleaner:

if (–m_refs == 0)
delete this;
}

from :

https://casablanca.codeplex.com/SourceControl/latest#Release/src/http/listener/http_linux_server.cpp
I ask because you once said you havent wrote delete in years. :)

Read More »

Comment on (V)C++ recorded talks at VS 2013 Launch by Herb Sutter

@nosenseetal: I’m not sure a circular buffer would be ideal — we don’t want to lose weak_ptrs while there are outstanding shared_ptrs and the number of outstanding live objects is not known in advance.

As for ‘delete this;’, it is overused and dangerous in the wrong hands, but it can be appropriate for an object that controls its own lifetime and you know you won’t have pointers or references to it. In this case, just from the snippet you provided you can see the object is probably using intrusive reference counting and just implementing it by hand. I might prefer using standard smart pointers instead of reimplementing it by hand, possibly including using enable_shared_from_this if appropriate, but I haven’t inspected the code.

Read More »
 
Delievered to you by Feedamail.
Unsubscribe