REVIEW - C++ Initialization Story - A Guide Through All Initialization Options and Related C++ Areas


Title:

C++ Initialization Story

A Guide Through All Initialization Options and Related C++ Areas

Author:

Bartłomiej Filipek

Publisher:

Leanpub (2023)

Pages:

270

Reviewer:

Paul Floyd

Reviewed:

January 2024

Rating:

★★★★☆


Verdict: Recommended

Whilst this book does cover C++ initialisation it nonetheless cuts a fairly wide swathe through the C++ language and library. Initialisation comes up in a large number of places. Obviously there is the initialisation (or not) that happens when you create a new local variable or allocate a new variable with dynamic allocation. There there are all those things that get created as side effects - function call arguments and return values. Then there are all the ways that objects can wind up being initialised - the special functions that are the constructor, copy constructor, copy assignment and move variants. Generally these aren’t too complicated but C++ does have some tricks up its sleeves like the infamous “most vexing parse”. That’s why we need books like this.

Modern C++ has non-static data member initialisation. Whilst it generally makes lives easier it’s another complication that has to co-exist with the existing mechanisms. That’s 19 pages of the book to cover all that. In order to initialise things you need to know their type. In the case of templates that is not always obvious so there’s a chapter on that.

Due to the convoluted history of C++ there are now several ways to initialise things. In particular there is the not quite universal brace initialisation that has several gotchas. std::initializer_list is in the same boat, usually convenient but with the occasional pitfall. I think that they are well explained in this book.

There are plenty of example snippets with links to godbolt, cppinsights and wandbox. I must admit I haven’t had the time to check them out.

Since this book is fairly narrow in its scope, if you are interested in getting it then you need to already have a decent understanding of C++. I think it’s a fair choice if you want to brush up on your C++ especially as it covers all versions of C++ up to 20.

Website: https://leanpub.com/cppinitbook






Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.