This presentation from Stephan Lavavej could have been entitled “Compiler Knows Best” – he rockets through numerous examples where the advice is to write less code and let the compiler do the right thing.
Here’s a slide of one of the key messages:
Other highlights for me:
- decltype(auto) coming in C++14 looks very cool (eliminates duplicate code when using auto with decltype for late-specified return values)
- Don’t call std::make_pair( x, y ) – the T, U are inferred by template argument deduction, so should always be left out (unless you want to force a type conversion when T != typeof(x) e.g. short -> long
- Use nullptr because it is convertable to all pointer types, but 0 and NULL are always type int
I love the new features of C++11 and couldn’t have written some of the cool libraries I’m working on without them. But – presentations like this make me concerned for the complexity of the language and the steep learning curve that even experienced C++ hires will have to climb.