Saturday, 30 September 2017

c++11 - Is effective C++ still effective?



From what I saw in this post I decided to start reading the book Effective C++.




But now that there are many new features because of C++11 and that a few of the good practices changed, I'm not sure whether or not it is actually a good idea. Has the advent of C++11 deprecated any of the advice contained in Effective C++? If so, which topics should I avoid?


Answer



This what Scott Meyers himself had to say about it on his own blog




Which may lead you to wonder whether the information and advice in
this pre-C++0x edition of Effective C++ remains relevant. I'm pleased
to report that it does. Surprisingly so, in fact. Having spent nearly
two years steeped in the details of C++0x, I expected to groan a bit
as I reviewed this book's table of contents with C++0x in mind. Surely

some Items would be inappropriate. But the advice I found proved
sound. Should C++0x developers prefer consts, enums, and inlines to
#defines (Item 2)? They should. Should they prevent exceptions from
leaving destructors (Item 8)? Certainly. Should they use objects to
manage resources? Declare data members private? Consider alternatives
to virtual functions? Factor parameter-independent code out of
templates? (Items 13, 22, 35, and 44.) Yes, yes, yes, yes! My goal has
always been for Effective C++'s table of contents to summarize the
advice in the book, and that summary remains just as applicable to
C++0x development as to “traditional” C++ development. C++0x is a

bigger language, and in some ways it's a different one, but the core
techniques for making effective use of “old” C++ are core for the
effective use of C++0x, too.



This doesn't mean that this Effective C++ is a perfect match for
C++0x. The book doesn't discuss features new to C++0x, so Items about
making effective use of those features are missing. A C++0xified
Effective C++ would certainly have Items devoted to move operations,
to uniform initialization, and to lambda expressions, and it'd probably have an entire chapter on making effective use of the concurrency API. Such a book would also contain different examples, e.g., ones making use of auto variables, range-based for loops, in-class default initializers, as well as the occasional variadic template. To the extent that this book falls short in its support for C++0x, the errors are those of omission, not commission.





UPDATE: the new title Effective Modern C++ has been for sale since November 2014 from O'Reilly and Amazon (and many others that you can google for).


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...