Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Embracing modern C++ safely
Lakos J., Romeo V., Khlebnikov R., Meredith A., Addison-Wesley Professional, Boston, MA, 2021. 1376 pp. Type: Book (978-0-137380-35-0)
Date Reviewed: Oct 3 2022

Embracing modern C++ safely is for professionals involved in large-scale projects using the C++ programming language. It describes various safe, conditionally safe, and unsafe features in C++11 and C++14. Each feature covered includes descriptions, some historical perspective, usage with code listings, use cases, pitfalls, annoyances, and references.

Chapter 0 looks at factors affecting safety decisions: severity of known deficiencies, difficulty in teaching, experience required for proper use, and risks of misuse. The chapter also guides readers on how to use the book.

Chapter 1 begins by noting that abstraction (annotation) support can be used for achieving portable code across C++ compilers and static analyzers. It discusses angular brackets and decltype usage via examples; the implicit generation of special member functions (constructors, destructors, copy, move) and ways to default them; and then continues the discussion with delete features. The chapter notes how implicit conversions can be problematic and advises using explicit conversions. It discusses the guarantee of no data races for concurrent use of function-scoped statics; the use of unnamed or local types in templates; and noreturn standard abstraction, long long type, nullptr, override, unicode string literals, and raw string literals. The chapter also introduces compile-time assertions and extended typedefs. Following its coverage of safe C++11 features, the chapter turns to safe C++14 features. This includes descriptions of sequence bit literals, new ways of member initialization, the standard attribute for indicating deprecation, digit separators, and applying templates on variables.

The second chapter begins by discussing how to use aligns. It covers compiler inferred types for auto variables and compile-time function evaluations using constexpr; initializers and explicit instantiations using extern templates; initializers with braces for user-defined types and containers; plain old data features in C++11; standard layouts and trivial layouts, along with the expected data layouts; correct ways of inheriting constructors; and lambda functions/expressions. It discusses exception safety with the noexcept operator and shows how the efficient moving of objects can be achieved using rvalue references. It also looks at convenient foreach loops, opaque enumerations, and enumerations with explicit values, as well as how to use user-defined literals. The last C++11 feature discussed is variadic templates. This lengthy discussion includes variable type parameters of templates, associated classes, associated functions, type deductions, and related packing/expansions. On the C++14 side, the chapter begins by showing what restrictions are removed in C++14 for const_expr. It also shows the extensions of lambdas in C++14.

Chapter 3 is on unsafe features, which are characterized as having high risk and little value. The chapter talks about the carries_dependency attribute and shows how the final feature is risky when used for preventing overrides of virtual functions, destructors, and user-defined types. It describes friend function extensions, inline namespaces, exception throwing/not throwing, reference qualifiers, and unions of C++11. For C++14, the auto return of functions and decltype of auto are described.

The book can be used for training C++ developers in the C++11 and C++14 versions. The authors have chosen to use the terms safe/unsafe instead of patterns/anti-patterns or good practices/bad practices. It is intended to be used as a reference book.

More reviews about this item: Amazon

Reviewer:  Maulik A. Dave Review #: CR147499 (2212-0155)
Bookmark and Share
  Featured Reviewer  
 
C++ (D.3.2 ... )
 
Would you recommend this review?
yes
no
Other reviews under "C++": Date
A C++ toolkit
Shapiro J., Prentice-Hall, Inc., Upper Saddle River, NJ, 1991. Type: Book (9780131276635)
Dec 1 1991
Borland C++ handbook
Pappas C., William H. I., McGraw-Hill, Inc., New York, NY, 1991. Type: Book (9780078810152)
Feb 1 1993
Going from C to C++
Traister R., Academic Press Prof., Inc., San Diego, CA, 1993. Type: Book (9780126974126)
Apr 1 1994
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2023 ThinkLoud®
Terms of Use
| Privacy Policy