REVIEW - Embracing Modern C++ Safely


Title:

Embracing Modern C++ Safely

Author:

John Lakos, Vittorio Romeo, Rostislav Khlebnikov, Alisdair Meredith

Publisher:

Pearson (2021)

Pages:

1303

Reviewer:

Paul Floyd

Reviewed:

March 2025

Rating:

★★★☆☆


Recommended with reservations.

This could have been the next ‘Meyers’ C++ book. However, it has one problem. A big problem. It is just too big. I was really enthusiastic when I started reading. Bite-sized chunks well written by experts. Great, I thought.

Then the bite-sized chunks started getting bloated. Instead of say 5 pages for a topic, sections started hitting double, then triple digit page counts. Probably the worst offender is the section on Generalized PODs ‘11. Or PODzzzz I should say. A few times I had that experience that I imagine a few readers of this review will have experienced. You get to the end of a page and you realise that your attention had wandered and none of it sank in. So you read it again, and again your concentration evaporates. After the third try you just give up.

Not helping much is that one of the authors has a beehive in his bonnet about narrow interfaces. So we get not one but two sections on noexcept (the Operator and the Specifier). Adding to the page count are a large glossary (occasionally useful if you are not fully up to steam with C++ acronyms) and a lengthy bibliography.

The book is split into 3 sections, Safe, Conditionally Safe and Unsafe features. Each of these is split into smaller sections, about 50 or so. There are fewer Unsafe sections than the other two. I suppose that means that C++ must have been doing most things right(-ish). I’ll just list a few in each category as a taster. Safe: nullptr, override and using aliases. Conditionally safe: braced init, range for and auto variables. Unsafe: noexcept (of course) and final (too restrictive).

Getting back to a couple of those sections. nullptr is a bit over 4 pages long. Excellent! Generalized PODs bangs on for 134 pages. The section describes several different categories of user defined types (PODs, aggregates, trivially copyable etc.). It then goes into painful detail as to what exactly constitutes each of these categories with endless code snippets with comments explaining why it is or isn’t of the given category and what you can and cannot do with that type. I can see that compiler writers need to know this stuff so that they can use functions like memcpy for faster copying. For any normal C++ developer, there is far too much detail.

There are a couple of ‘guest chapters’ by Andrei Alexandrescu (far beyond my template pack abilities) and Sean Parent (on the performance impact of the C++ standard requirements on moved-from objects).

Who is going to benefit from this book? It’s not really a learning book (unless you are planning on joining the C++ committee or becoming a compiler writer or both). The shorter sections stand up well as references. I can’t see anyone wading through the 100+ pages on noexcept just to check on some detail. I don’t know of any similar book, so I suppose that it could be considered to be a flawed reference.

Maybe this book will grow on me (like Stroustrup’s C++ Programming Language). The quality is definitively in there somewhere.

Website: https://www.pearson.com/en-gb/subject-catalog/p/embracing-modern-c-safely/P200000009514/9780137380510

Code: https://emcpps.com/






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.