5

Since the book Effective C++ seems to be still worth reading and the best to start with from the Effective C++ series, I wonder which suggested solutions/implementations I need not understand in detail/memorize because there are better solutions in C++11 or later. So:

Which Effective C++ Items can be implemented much simpler or better via C++11 or later? How can they be implemented now, and in which way is it better?


Details:

Since there are many C++ idioms deprecated in C++11, I guess this also influences the solutions in the Effective C++ book. For example, looking at its table of contents, I guess (since I have not yet read the book) that

  • Item 6 (Explicitly disallow the use of compiler-generated functions you do not want) becomes simpler via =delete
  • Item 17 (Store newed objects in smart pointers in standalone statements) becomes simpler via make_shared (and C++14's make_unique)
  • Item 21 (Don't try to return a reference when you must return an object) becomes simpler and more efficient via move semantics
  • Item 55 (Familiarize yourself with Boost) now has fewer examples because many boost features are also part of C++11 or later.

Correct? Any more? How are these Items implemented in modern C++?

Community
  • 1
  • 1
DaveFar
  • 7,078
  • 4
  • 50
  • 90
  • 2
    The moral of those points hasn't changed. C++11 perhaps gives you better ways of writing code that follows those ideas, but that's ultimately a detail. You should never get hung up on any one particular detail, and instead appreciate what problem is being solved and why the problem exists in the first place. – Kerrek SB Jun 12 '16 at 21:07
  • 2
    Some of these are addressed in Effective Modern C++, for whatever that's worth. In all honestly, it's a good place to start on this. – chris Jun 12 '16 at 21:11
  • 1
    In all likelihood you'll encounter both pre and post c++ code in you career. I would read both books if I were you. – Richard Hodges Jun 12 '16 at 21:13

1 Answers1

6

Many recipes from Effective C++ still apply with C++11. By the way, Effecive Modern C++ focuses on C++11 changes.

The question is very broad, but this comes to my mind:

5) Still true, but don't forget the move constructor and assignment.
6) Still true, but now easier, as you already explained
13) Principle still true but forget auto_ptr and used shared_ptr and unique_ptr
14) Still true, but simplified with shared_ptr.
17) Still true, but now easier, as you already explained
18) Still true, but prefer enum classes to enums.
54) Still applies, but to new libraries
55) Still true, although more boost features are now in the standard

Many examples could be simplified, using auto or range for

Christophe
  • 68,716
  • 7
  • 72
  • 138