Verdict: Highly Recommended.
I’ve often read parts of Bartek’s blog (https://www.cppstories.com/p/about/) so was delighted to get a review copy of his book about C++ initialisation. Many recent C++ books focus on a specific standard, giving a throughout rundown of all the features introduced. They end up being big books which work well as a reference book, but are hard to read from cover to cover.
Bartek’s book breaks the mould. He walks through various ways to initialize variables in C++. How hard can it be? Well, even though we have the uniform initialization syntax, using {}
, there are subtleties. The book starts simply with local objects, progressing to classes and much more besides. Things to consider for construction, destruction, lifetimes rules and template deduction are also included, and the final chapter provides some techniques, such as the copy and swap idiom and the Curiously Recurring Template Pattern (CRTP: see https://en.cppreference.com/w/cpp/language/crtp). There are short quizzes part way through and at the end, and these helped remind me of a few things I had just learnt, so were useful.
The book is well paced, with chapters up to 20 pages or so, arranged in a logical order starting simply and building up. The subtitle is ‘A Guide Through All Initialization Options and Related C++ Areas.’ As well as initialization, he shows where things go wrong if you don’t pay attention to details, and how you might end up making code less efficient by mistake.
People who consider themselves relatively well-versed in C++ will still learn something from this book, while anyone starting out will also find this useful. I knew a lot of what’s included, but learnt many new things or gained a deeper understanding of why certain approaches are better. I will re-read this. Any book that will be read and re-read is definitely 5 stars.
Website: https://leanpub.com/cppinitbook