REVIEW - C++17 In Detail - Learn the Exciting Features of the New C++ Standard!


Title:

C++17 In Detail

Learn the Exciting Features of the New C++ Standard!

Author:

Bartłomiej Filipek

Publisher:

Independently Published (2019)

Pages:

378pp

Reviewer:

Paul Floyd

Reviewed:

March 2020

Rating:

★★★★★


This book is available with continuous updates: https://leanpub.com/cpp17indetail

Highly recommended

C++17 is the second iteration following a three year cycle and at the end of last year (2019) we started getting some books specific to C++17. I felt that C++14 got fairly thin coverage in the publishing world (Programming Principles and Practice, Effective Modern C++ and that’s about it). C++17 seems to be doing better, with second editions of C++ Templates, A Tour of C++ and C++ Concurrency in Action already. Perhaps authors and publishers are having a harder time keeping up with C++ versions? Perhaps also there’s more to write about in C++17.

Getting back to the book itself, the book covers only the new features of C++17. You will need to have to have a good understanding of C++ to be able to get much benefit from the book. The first example on page 3 illustrates several new features. If you are not familiar with std::map , brace initialisation, auto and range based for then you won’t appreciate how much is new.

The book is broken down into three parts: language, library and use cases. There is plenty of information in each chapter on the C++ Standards Committee papers, where the various changes were proposed, and also of which compilers and versions support each feature. The first few chapters cover some fairly basic items that clean up and simplify the language. I expect that Python programmers will appreciate the new Structured Bindings. Chapter 5 Templates (including fold expressions and ‘ if constexpr ’). In my opinion these are the most important changes in C++17 (especially ‘ if constexpr ’) which continue the process of enabling easier and more powerful template programming. The language part ends with a chapter on attributes.

The second part covers the library. The first three items – std::optional , std::variant and std::any – have been with us for some time in boost::guise . It’s good to see these in the library and I think that they will be very useful tools. I likes the coverage of performance and exceptions, and there are also summaries of changes from the boost::versions .

The next three chapters are dedicated to strings: std::string_view , string conversions and string searching. Searching isn’t really up my street, but it’s always good to know. string_view and the conversions look promising, at least from a performance perspective. I had already heard some misgivings about the risks of using string_view , and that is well covered. The next two chapters are big items: Filesystem and Parallel Algorithms. There is a lot to cover for filesystems, but everything is covered albeit briefly, and there are a few decent examples of using the interface. Parallel Algorithms is mostly about performance. A little niggle here, I would have liked to see some more useful example for the uses of std::reduce / std::transform_reduce , for instance the variance with an explanation of why std::reduce is not suitable for such calculations. There is a fair amount of performance analysis. The last two chapters of Part 2 cover small items and standard library cleanup.

The last part is a brief overview of some use cases. The first three are refactoring using optional/variant , [[nodiscard]] and if constexpr . The last example parallelises a CSV file reader.

I enjoyed reading the book. It is concise enough that I could read it all in a few days whilst at the same time giving enough coverage that I had a clear impression of the new additions to C++17.






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.