Effective C++11?

Although maybe still a year or two away, it looks like there may be some progress with Scott Meyers’ update to what has historically been the standard second book of C++, Effective C++.

Meyers has a talk planned for the ‘C++ and Beyond’ conference later this year teasingly entitled ‘Initial Thoughts on Effective C++11’. He has already listed a number prospective guidelines:

  • Prefer auto to Explicit Type Declarations
  • Distinguish () and {} When Creating Objects
  • Remember that auto + { expr } == std::initializer_list
  • Prefer non-member begin/end to member versions
  • Declare std::thread Members Last in Classes
  • Be Wary of Default Capture Modes in Lambdas Escaping Member Functions
  • Prefer Emplacement to Insertion
  • Pass std::launch::async if Asynchronicity is Essential
  • Minimize use of Weak Atomics
  • Distinguish Rvalue References from Universal References
  • Assume that move operations are neither present nor cheap
  • Prefer Lambdas over Binders
  • Prefer Lambdas over Variadic Arguments to Threading Functions
  • Be Wary of Oversubscription
  • Apply std::forward when Passing Universal References
  • Prefer std::array to Built-in Arrays
  • Use std::make_shared Whenever Possible
  • Prefer Pass-by-Reference-to-const to Pass-by-Value for std::shared_ptrs
  • Pass by Value if You’ll Copy Your Parameter
  • Reserve noexcept for Functions with Wide Interfaces
  • For Copyable Types, View Move as an Optimization of Copy
  • Prefer enum classes to enums
  • Prefer nullptr to NULL and 0
  • Distinguish among std::enable_if, static_assert, and =delete

All subject to change, of course, and to get some feedback he has opened up a discussion, inviting comments on the list as well as requesting any additional items:



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: