Book description
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++.
Topics include:
- The pros and cons of braced initialization, noexcept specifications, perfect forwarding, and smart pointer make functions
- The relationships among std::move, std::forward, rvalue references, and universal references
- Techniques for writing clear, correct, effective lambda expressions
- How std::atomic differs from volatile, how each should be used, and how they relate to C++'s concurrency API
- How best practices in "old" C++ programming (i.e., C++98) require revision for software development in modern C++
Effective Modern C++ follows the proven guideline-based, example-driven format of Scott Meyers' earlier books, but covers entirely new material.
"After I learned the C++ basics, I then learned how to use C++ in production code from Meyer's series of Effective C++ books. Effective Modern C++ is the most important how-to book for advice on key guidelines, styles, and idioms to use modern C++ effectively and well. Don't own it yet? Buy this one. Now".
-- Herb Sutter, Chair of ISO C++ Standards Committee and C++ Software Architect at Microsoft
Publisher resources
Table of contents
- Copyright/Revision History
- From the Publisher
- Acknowledgments
- Introduction
- 1. Deducing Types
- 2. auto
-
3. Moving to Modern C++
- Item 7: Distinguish between () and {} when creating objects.
- Item 8: Prefer nullptr to 0 and NULL.
- Item 9: Prefer alias declarations to typedefs.
- Item 10: Prefer scoped enums to unscoped enums.
- Item 11: Prefer deleted functions to private undefined ones.
- Item 12: Declare overriding functions override.
- Item 13: Prefer const_iterators to iterators.
- Item 14: Declare functions noexcept if they won’t emit exceptions.
- Item 15: Use constexpr whenever possible.
- Item 16: Make const member functions thread safe.
- Item 17: Understand special member function generation.
-
4. Smart Pointers
- Item 18: Use std::unique_ptr for exclusive-ownership resource management.
- Item 19: Use std::shared_ptr for shared-ownership resource management.
- Item 20: Use std::weak_ptr for std::shared_ptr-like pointers that can dangle.
- Item 21: Prefer std::make_unique and std::make_shared to direct use of new.
- Item 22: When using the Pimpl Idiom, define special member functions in the implementation file.
-
5. Rvalue References, Move Semantics, and Perfect Forwarding
- Item 23: Understand std::move and std::forward.
- Item 24: Distinguish universal references from rvalue references.
- Item 25: Use std::move on rvalue references, std::forward on universal references.
- Item 26: Avoid overloading on universal references.
- Item 27: Familiarize yourself with alternatives to overloading on universal references.
- Item 28: Understand reference collapsing.
- Item 29: Assume that move operations are not present, not cheap, and not used.
- Item 30: Familiarize yourself with perfect forwarding failure cases.
- 6. Lambda Expressions
-
7. The Concurrency API
- Item 35: Prefer task-based programming to thread-based.
- Item 36: Specify std::launch::async if asynchronicity is essential.
- Item 37: Make std::threads unjoinable on all paths.
- Item 38: Be aware of varying thread handle destructor behavior.
- Item 39: Consider void futures for one-shot event communication.
- Item 40: Use std::atomic for concurrency, volatile for special memory.
- 8. Tweaks
- Index
Product information
- Title: Effective Modern C++
- Author(s):
- Release date: November 2014
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781491903995
You might also like
book
Head First Design Patterns, 2nd Edition
You know you don’t want to reinvent the wheel, so you look to design patterns—the lessons …
book
Fundamentals of Software Architecture
Salary surveys worldwide regularly place software architect in the top 10 best jobs, yet no real …
book
Software Engineering at Google
Today, software engineers need to know not only how to program effectively but also how to …
book
The Pragmatic Programmer: your journey to mastery, 20th Anniversary Edition, 2nd Edition
"One of the most significant books in my life." —Obie Fernandez, Author, The Rails Way "Twenty …