Archive for October 28th, 2011


As I’m getting ready to resume writing a few new (or updated) Guru of the Week Items for the C++11 era, I’ve been looking through the wonderful features of C++11 and analyzing just which ones will affect the baseline style of how I write modern C++ code, both for myself and for publication.

I’ve gathered the results in a short page. Here’s the intro:

Elements of Modern C++ Style

“C++11 feels like a new language.” – Bjarne Stroustrup

The C++11 standard offers many useful new features. This page focuses specifically and only on those features that make C++11 really feel like a new language compared to C++98, because:

  • They change the styles and idioms you’ll use when writing C++ code, often including the way you’ll design C++ libraries. For example, you’ll see more smart pointers, and functions that return big objects by value.
  • They will be used so pervasively that you’ll probably see them in most code examples. For example, virtually every five-line modern C++ code example will say “auto” somewhere.

Use the other great C++11 features too. But get used to these ones first, because these are the pervasive ones that show why C++11 code is clean, safe, and fast – just as clean and safe as code written in any other modern mainstream language, and with C++’s traditional to-the-metal performance as strong as ever.

Like Strunk & White, this page is deliberately focused on brief summary guidance. It is not intended to provide exhaustive rationale and pro/con analysis; that will go into other articles.

I hope you find it useful.

Apologies in advance if some of the code snippets are odd or missing template argument lists. Let me know and I’ll fix any I missed. I think I restored them all (again), but am still fighting my tools, which keep sporadically eating angle-bracket lists. Someday someone will integrate good code authoring in a good editor for a good blogging platform; today’s tools are at best “adequate.”

Read Full Post »