Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14

Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14

Scott Meyers

Language: English

Pages: 336

ISBN: 1491903996

Format: PDF / Kindle (mobi) / ePub

Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14

Scott Meyers

Language: English

Pages: 336

ISBN: 1491903996

Format: PDF / Kindle (mobi) / ePub


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

Perl & LWP

Logic Programming with Prolog

Oracle Business Intelligence 11g R1 Cookbook

Designing Interfaces (2nd Edition)

Facebook Application Development for Dummies

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

to copy operations in C++98 with calls to move operations in C++11 only if the move operations are known to not emit exceptions. But how can a func‐ tion know if a move operation won’t produce an exception? The answer is obvious: it checks to see if the operation is declared noexcept.3 swap functions comprise another case where noexcept is particularly desirable. swap is a key component of many STL algorithm implementations, and it’s commonly employed in copy assignment operators, too. Its

declarations? Are you interested in why const member functions should be thread safe, how to implement the Pimpl Idiom using std::unique_ptr, why you should avoid default capture modes in lambda expressions, or the differences between std::atomic and volatile? The answers are all here. Furthermore, they’re platform-independent, Standards-conformant answers. This is a book about portable C++. The Items in this book are guidelines, not rules, because guidelines have exceptions. The most important

declarations? Are you interested in why const member functions should be thread safe, how to implement the Pimpl Idiom using std::unique_ptr, why you should avoid default capture modes in lambda expressions, or the differences between std::atomic and volatile? The answers are all here. Furthermore, they’re platform-independent, Standards-conformant answers. This is a book about portable C++. The Items in this book are guidelines, not rules, because guidelines have exceptions. The most important

deleter of arbitrary size without using any more memory? Item 19 | 127 It can’t. It may have to use more memory. However, that memory isn’t part of the std::shared_ptr object. It’s on the heap or, if the creator of the std::shared_ptr took advantage of std::shared_ptr support for custom allocators, it’s wherever the memory managed by the allocator is located. I remarked earlier that a std::shared_ptr object contains a pointer to the reference count for the object it points to. That’s true,

B will have been leaked, for all practical purposes: it will be impossible for the program to access them, yet their resources will never be reclaimed. • A std::weak_ptr. This avoids both problems above. If A is destroyed, B’s pointer back to it will dangle, but B will be able to detect that. Furthermore, though A and B will point to one another, B’s pointer won’t affect A’s reference count, hence can’t keep A from being destroyed when std::shared_ptrs no longer point to it. Using std::weak_ptr

Download sample

Download