C++11 is still C++ just a tiny bit easier
(JP 02/02/2015 originally presented with supporting slides from Herb Sutter Back To Basics)
Go through some of the C++11 feature and look at how it should impact our coding:
- Limited impact on how to write function and objects (Move is generally automatic).
- Biggest impact: We can now return big types instead of passing them as non const pointer or reference.
- Parameter as const reference is still the strongly preferred default.
- const pointer and reference are still the preferred way to give argument to function without ownership.
Supporting material: CppCon 2014: Herb Sutter “Back to the Basics! Essentials of Modern C++ Style”
- Back to the basics slides
- Video CppCon 2014: Herb Sutter “Back to the Basics! Essentials of Modern C++ Style” 1h40min
Some Highlights
- Using pointers:
* [http://youtu.be/xnqTKD8uD64?=12m8s From 12m8s until 28m22s(Page 5-6)]
- Use reference and raw pointer for non owning pointer as function arguments * [http://youtu.be/xnqTKD8uD64?t=22m59s From 22m59s until 28m22s (Page 9-10)]
- How to safely pointer from shared_ptr without risking dangling pointer
- Passing/ returning arguments
* [http://youtu.be/xnqTKD8uD64?t=51m5s From 51m5s until 59m (after that advance tools to avoid unless you write STL or Boost)(Page 22, 23, 24)]
- C++98 still mostly good default: Use return by value more often but don’t overuse pass by value
- [http://youtu.be/xnqTKD8uD64?t=57m32s From 57m32s until 59m]
- Summary table(‘'’Page 23/24)’’’=> C++98 vs C++11/14 guideline for passing an returning values
- Mostly the same, just more case of returning by value
Conclusion
- C++11 code will look a lot like C++98, do not throw away your good habits.
- Good benefit of C++11 move semantic is to make good looking code that return by value more efficient.
Presented at IndigoVision during a training session on 02/02/2015 with supporting slides from Herb Sutter.

This work by Jean-Philippe DUFRAIGNE is licensed under a Creative Commons Attribution 4.0 International License.