Coming to grips with C++11 and C++14 is more than a matter of familiarizing yourself with the features they introduce (e.g., auto type declarations, move semantics, lambda expressions, and concurrency support). The challenge is learning to use those features effectively—so that your software is correct, efficient, maintainable, and portable. That’s where this practical book comes in. It describes how to write truly great software using C++11 and C++14—i.e. using modern C++.
At first glance, C++11 and C++14 are defined by the new features they introduce, e.g., auto type declarations, move semantics, lambda expressions, and concurrency support. Information on these features is easy to come by, but learning to apply them effectively (such that the resulting software is correct, efficient, maintainable, and portable) is more challenging. That’s the role of this book. It describes how to write effective software using C++11 and C++14, i.e., using modern C++.
Topics include:
The pros and cons of uniform initialization, noexcept specifications, perfect forwarding, and smart pointer make functions.
The relationships among std::move, std::forward, rvalues references, and universal references.
The most effective forms of lambda capture.
How best practices in “old” C++ programming (i.e., C++98) require revision for modern C++.
Effective Modern C++ follows the proven format of Scott Meyers’ earlier Effective books (Effective C++, More Effective C++, and Effective STL), but covers entirely new material. It’s essential reading for every modern C++ software developer.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A practical, item-based guide to writing correct, efficient, and maintainable code with C++11 and C++14, ideal for experienced C++ developers transitioning from C++98 or seeking to master modern idioms like move semantics, type deduction, and smart pointers.
【Book Arc】
- **Opening (~0%–9%)**: Introduces the book's scope and terminology (e.g., raw vs. smart pointers, signatures, undefined behavior), then dives into template type deduction rules, distinguishing cases for references, universal references, and by-value parameters.
- **Early (~9%–25%)**: Explores `auto` and `decltype` type deduction, including pitfalls like braced initializers and how to use `decltype(auto)` for perfect forwarding in function templates.
- **Early (~25%–34%)**: Covers variable declaration best practices—preferring `auto` over explicit types, avoiding `std::function` for closures (due to heap allocation), and understanding proxy classes like `std::vector<bool>::reference`.
- **Middle (~34%–47%)**: Discusses initialization syntax (braces vs. parentheses), the most vexing parse, and `std::initializer_list` overload traps; then shifts to null pointer best practices (`nullptr` over `0`/`NULL`) and scoped enums (`enum class`) for type safety.
- **Late (~47%–end)**: Continues with advanced topics like `noexcept`, smart pointer `make` functions, and universal references, though excerpts thin out; the book closes with practical guidance on applying these idioms consistently.
【Key Takeaways】
- **Template type deduction has three cases** (Early): reference/pointer (non-universal), universal reference, and by-value; each has distinct rules (e.g., references are ignored, const is dropped for by-value). This is foundational for writing generic code.
- **`auto` type deduction differs from template deduction** (Early): `auto` treats braced initializers as `std::initializer_list`, while templates don't; C++14 `auto` return types and lambda params use template rules. This prevents subtle bugs in initialization.
- **`decltype` gives exact types, enabling `decltype(auto)`** (Early): Use it for perfect-forwarding function returns, like `authAndAccess`, to preserve references and constness; C++11 requires trailing return types.
- **Prefer `auto` over explicit types for variables** (Early): It avoids uninitialized variables and type mismatches, but beware proxy classes like `std::vector<bool>::reference` that can dangle; use `static_cast` to materialize values.
- **Braced initialization is "uniform" but has traps** (Middle): It prevents narrowing and vexing parse, but can hijack overloads via `std::initializer_list` (e.g., `std::vector<int>{10, 20}` creates 2 elements, not 10). Design constructors to avoid surprises.
- **Use `nullptr` instead of `0` or `NULL`** (Middle): In templates, `0` and `NULL` deduce as integral types, causing type errors; `nullptr` converts cleanly to any pointer type, avoiding overload ambiguity.
- **Prefer scoped enums (`enum class`)** (Middle): They prevent namespace pollution and implicit conversions to integral/floating types, catching errors like comparing a color to a double; use `std::underlying_type` for generic access.
【Reading Tips】
- **Deep-read Items 1–4** (type deduction) and Item 7 (initialization) carefully—they underpin most modern C++ pitfalls; skim the Boost.TypeIndex example in Item 4 if you're not using Boost.
- **Skim the "Things to Remember" summaries** at each item's end for quick reference; they distill the key rules without the detailed rationale.
- **Watch for cross-references** (e.g., Item 24 on universal references, Item 25 on `std::forward`); read them in sequence if you're new to move semantics, as they build on each other.
- **Practice with the `authAndAccess` example** (Item 3) to solidify `decltype(auto)` and perfect forwarding; it's a canonical pattern for generic container access.
- **Take away the "why" behind each rule** (e.g., why `auto` beats `std::function` for closures) to apply these idioms beyond the book's examples.
【Coverage Limits】
Excerpts cover roughly the first half of the book (Items 1–10); later items on smart pointers, `noexcept`, and concurrency are mentioned but not detailed here.
Page 1
mantics, lambda expressions, and concurrency support). The challenge is learning to use those features effectively—so that your how to use C++ in software ...
r implies template type deduction, not auto type deduction. Item 3: Understand decltype. decltype is an odd creature. Given a name or an expression, decltype...
sion that operator[] for std::vector<bool> returns a refer‐ ence to a bit, for example, and the Standard Library’s smart pointer types (see Chap‐ ter 4) are ...
space pollution offered by scoped enums is reason enough to prefer them over their unscoped siblings, but scoped enums have a second compelling advantage: th...
or of a function is of key interest to clients. Callers can query a function’s noexcept status, and the results of such a query can affect the exception safe...
are remarkably varied. About the only functionality common to all is default construction. Because comprehensive references for these APIs are widely availab...
using std::shared_ptrs everywhere, how can this code leak? The answer has to do with compilers’ translation of source code into object code. At runtime, the ...
move unconditionally casts its argument to an rvalue, while std::forward performs this cast only if a particular condition is fulfilled. That’s it. The expla...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Effective Modern C++ 42 Specific Ways to Improve Your Use of C++11 and C++14 (Scott Meyers)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Effective Modern C++ 42 Specific Ways to Improve Your Use of C++11 and C++14 (Scott Meyers)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment