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

By Scott Meyers

Coming to grips with C++11 and C++14 is greater than an issue of familiarizing your self with the gains they introduce (e.g., auto sort declarations, circulate semantics, lambda expressions, and concurrency support). The problem is studying to take advantage of these positive aspects effectively—so that your software program is right, effective, maintainable, and conveyable. That’s the place this useful e-book is available in. It describes the right way to write actually nice software program utilizing C++11 and C++14—i.e. utilizing modern C++.

Topics include:

  • The execs and cons of braced initialization, noexcept necessities, ideal forwarding, and shrewdpermanent pointer make functions
  • The relationships between std::move, std::forward, rvalue references, and common references
  • Techniques for writing transparent, right, effective lambda expressions
  • How std::atomic differs from volatile, how every one may be used, and the way they relate to C++'s concurrency API
  • How top practices in "old" C++ programming (i.e., C++98) require revision for software program improvement in glossy C++

Effective smooth C++ follows the confirmed guideline-based, example-driven layout of Scott Meyers' previous books, yet covers totally new material.

"After I realized the C++ fundamentals, I then discovered the way to use C++ in creation code from Meyer's sequence of powerful C++ books. Effective glossy C++ is crucial how-to booklet for recommendation on key directions, kinds, and idioms to exploit sleek C++ successfully and good. do not personal it but? purchase this one. Now".
-- Herb Sutter, Chair of ISO C++ criteria Committee and C++ software program Architect at Microsoft

Show description

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

Best Programming books

Joe Celko's SQL for Smarties: Advanced SQL Programming Third Edition (The Morgan Kaufmann Series in Data Management Systems)

SQL for Smarties was once hailed because the first e-book dedicated explicitly to the complex strategies had to remodel an skilled SQL programmer into knowledgeable. Now, 10 years later and within the 3rd variation, this vintage nonetheless reigns very best because the publication written by way of an SQL grasp that teaches destiny SQL masters.

Designing Audio Effect Plug-Ins in C++: With Digital Audio Signal Processing Theory

Not only one other theory-heavy electronic sign processing publication, nor one other boring build-a-generic-database programming e-book, Designing Audio impact Plug-Ins in C++ promises every thing you every little thing you must recognize to do exactly that, together with totally labored, downloadable code for dozens audio influence plug-ins and virtually offered algorithms.

Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)

“Every C++ specialist wishes a replica of potent C++. it truly is an absolute must-read for an individual taking into consideration doing severe C++ improvement. If you’ve by no means learn powerful C++ and also you imagine you recognize every little thing approximately C++, re-evaluate. ”— Steve Schirripa, software program Engineer, Google “C++ and the C++ group have grown up within the final fifteen years, and the 3rd version of potent C++ displays this.

Cocoa Design Patterns

“Next time a few child exhibits up at my door inquiring for a code evaluation, this is often the publication that i'm going to throw at him. ”   –Aaron Hillegass, founding father of enormous Nerd Ranch, Inc. , and writer of Cocoa Programming for Mac OS X   Unlocking the secrets and techniques of Cocoa and Its Object-Oriented Frameworks   Mac and iPhone builders are usually beaten by way of the breadth and class of the Cocoa frameworks.

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

Show sample text content

A functionality with a large agreement has no preconditions. this type of functionality could be referred to as whatever the kingdom of the professional‐ gram, and it imposes no constraints at the arguments that callers move it. five capabilities with broad contracts by no means express undefined habit. capabilities with no vast contracts have slim contracts. For such features, if a pre‐ is violated, effects are undefined. If you’re writing a functionality with a large agreement and also you understand it won’t emit excep‐ tions, following the recommendation of this merchandise and stating it noexcept is simple. For func‐ tions with slender contracts, the location is trickier. for instance, consider you’re writing a functionality f taking a std::string parameter, and think f’s typical imple‐ mentation by no means yields an exception. that means that f might be declared noex cept. Now believe that f has a precondition: the size of its std::string parameter doesn’t exceed 32 characters. If f have been to be known as with a std::string whose size is larger than 32, habit will be undefined, simply because a precondition violation through definition leads to undefined habit. f is lower than no legal responsibility to examine this pre‐ , simply because capabilities may possibly suppose that their preconditions are chuffed. (Call‐ ers are chargeable for making sure that such assumptions are legitimate. ) inspite of a precondition, then, mentioning f noexcept turns out acceptable: void f(const std::string& s) noexcept; // precondition: // s. length() <= 32 yet consider that f’s implementer chooses to examine for precondition violations. Checking isn’t required, yet it’s additionally now not forbidden, and checking the precondition can be valuable, e. g. , in the course of process trying out. Debugging an exception that’s been thrown is mostly more uncomplicated than attempting to music down the reason for undefined habit. yet how may still a precondition violation be said such try harness or a cli‐ ent mistakes handler may discover it? an easy technique will be to throw a “precondition used to be violated” exception, but when f is asserted noexcept, that will be most unlikely; throwing an exception could bring about application termination. For this rea‐ five “Regardless of the country of this system” and “no constraints” doesn’t legitimize courses whose habit is already undefined. for instance, std::vector::size has a large agreement, yet that doesn’t require that it behave kind of for those who invoke it on a random bite of reminiscence that you’ve forged to a std::vector. the results of the solid is undefined, so there are not any behavioral promises for this system containing the solid. merchandise 14 | ninety five son, library designers who distinguish extensive from slender contracts normally reserve noexcept for features with vast contracts. As a last element, enable me difficult on my previous commentary that compilers in most cases supply no assist in deciding on inconsistencies among functionality implementations and their exception requirements. think about this code, that's completely felony: void setup(); void cleanup(); void doWork() noexcept { setup(); // features outlined somewhere else // organize paintings to be performed … // do the particular paintings cleanup(); // practice cleanup activities } the following, doWork is asserted noexcept, although it calls the non-noexcept services setup and cleanup.

Download PDF sample

Rated 4.55 of 5 – based on 6 votes