Effective Modern C++

by Piotr Likus on April 19, 2015
Overview
Item Reviewed

Effective Modern C++. 42 Specific Ways To Improve Your Use Of C++11 and C++14.

Author
April 19, 2015
Book author(s)

Scott Meyers

Publisher

O'Reilly Media Inc.

ISBN(s)

978-1-4919-0399-5, 1-4919-0399-6

Pages

336

Publication year

2015

Overview

Scott Meyers is a software consultant specializing in C++ programming language. You can find many presentations performed by him on the internet. His way of speaking is very positive, intriguing and sometimes funny but at the same time he likes to present traps you can find when developing computer programs in C++. And this the way he writes programming books.

“Effective Modern C++” is well organized into 42 points describing new language features in a way that I assume is best suitable for experienced C++ developers already knowing C++11/14 but in the same time willing to use it effectively.

This book does not describe the whole new standard. Some parts of new language standard are not presented at all (“final”) or very briefly (“static_assert”, type traits, concurrency), so don’t expect to learn all the new features of C++11/14 from this book.

Arguable items

Author selected 2 points that even if his opinion are optional to follow and described them in special chapter “Tweaks”. I found two more which for me are arguable.

Item 5: prefer auto to explicit type declarations.

This item seamed for me arguable at the start but at the end it’s not. When scanning containers it’s important to use same type as container limits for variables:

std::vector<int> v;
...
std::vector<int>::size_type sz = v.size();
std::vector<int>::size_type idx = 0;

But with auto it’s much shorter, easier to read & maintain:

std::vector<int> v;
...
auto sz = v.size();
decltype(sz) idx = 0;

I would say that in examples Meyers presented he is 100% correct.

Item 9: prefer alias declarations to typedefs.

Author shows various valid reasons to prefer “using” instead of “typedef” but then, in item 12 at the end he uses “using” for simple case like

using DataType = std::vector<double>;

where “typedef” would be as useful as “using”. Is really “using” declaration supposed to replace typedef?

Weak points

There are some items which clearly describe language flaws (features). It seams a little depressing for me, but at the end I can say it’s required to read them if you want to use smart pointers or rvalue references.

These features are:

  • perfect forwarding which isn’t perfect
  • universal (rvalue) references – long and painful explanation why this type of references can fail
  • PIMPL implementation which with std::unique_ptr is not so easy as with raw pointers

Additional resources

1) Video introduction

2) Errata

Positives

* well organized
* presents comprehensive explanation of reasons for recommendations
* colourful printout easy to read

Negatives

* some parts of new language standard are not described

Rating
Our Rating
User Rating
Rate Here
Rating
Bottom Line

Good appendix to C++11/14 language standard. A must-have if you are serious about new language standard.

Total Score
User Score
1 rating
You have rated this
Fonts by Google Fonts. Icons by Fontello. Full Credits here »