Wednesday, September 18, 2013

Questionable advice

Newsgroup: comp.lang.c++

Subject: Questionable advice

From: woodbrian77@...

Date: Sun, 8 Sep 2013 09:28:53 -0700 (PDT)





I watched some of the videos from the C++ conference at

Microsoft. Some of the advice given was to not use raw

pointers for ownership. I think that's going too far.



http://webEbenezer.net/misc/SendBuffer.hh

http://webEbenezer.net/misc/SendBuffer.cc



Someone may say that that doesn't scale if we need to

add another pointer to the class. I disagree. Classes

can have at least one pointer that isn't wrapped with

a smart pointer.



http://webEbenezer.net/misc/SendBufferCompressed.hh

http://webEbenezer.net/misc/SendBufferCompressed.cc



Finally, at the conference STL pointed out that using a

delegated constructor you can safely have multiple raw

pointers in a class:



http://webEbenezer.net/misc/Compressed.hh

http://webEbenezer.net/misc/Compressed.cc



Previously I was using unique_ptr more than now, but

have found in each of these cases that the code that

results without using it so much is a little smaller.

I've seen a lot of overuse of shared_ptr over the years

and now think it's also possible to use unique_ptr too

much.



The simplified advice came from Bjarne. I think for

student programs it doesn't make much difference, but

he may be focussing too much on beginners these days.





Brian

Ebenezer Enterprises - In G-d we trust.

http://webEbenezer.net







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?83905-Questionable-advice&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

No comments:

Post a Comment