richelbilderbeek / cpp

My pages about C++
http://richelbilderbeek.nl/
GNU General Public License v3.0
52 stars 15 forks source link

Add Scott Meyer's advice #2

Open richelbilderbeek opened 7 years ago

richelbilderbeek commented 7 years ago

From @richelbilderbeek on October 4, 2015 10:49

From @richelbilderbeek on June 1, 2014 15:22

From http://cppandbeyond.com/2012/04/16/session-topic-initial-thoughts-on-effective-c11:

    Prefer auto to Explicit Type Declarations
    Distinguish () and {} When Creating Objects
    Remember that auto + { expr } == std::initializer_list
    Prefer non-member begin/end to member versions
    Declare std::thread Members Last in Classes
    Be Wary of Default Capture Modes in Lambdas Escaping Member Functions
    Prefer Emplacement to Insertion
    Pass std::launch::async if Asynchronicity is Essential
    Minimize use of Weak Atomics
    Distinguish Rvalue References from Universal References
    Assume that move operations are neither present nor cheap
    Prefer Lambdas over Binders
    Prefer Lambdas over Variadic Arguments to Threading Functions
    Be Wary of Oversubscription
    Apply std::forward when Passing Universal References
    Prefer std::array to Built-in Arrays
    Use std::make_shared Whenever Possible
    Prefer Pass-by-Reference-to-const to Pass-by-Value for std::shared_ptrs
    Pass by Value if You’ll Copy Your Parameter
    Reserve noexcept for Functions with Wide Interfaces
    For Copyable Types, View Move as an Optimization of Copy
    Prefer enum classes to enums
    Prefer nullptr to NULL and 0
    Distinguish among std::enable_if, static_assert, and =delete

Copied from original issue: richelbilderbeek/ProjectRichelBilderbeek#216

Copied from original issue: richelbilderbeek/RichelbilderbeekNl#3

richelbilderbeek commented 7 years ago

Todo:

    Distinguish () and {} When Creating Objects
    Be Wary of Default Capture Modes in Lambdas Escaping Member Functions
    Prefer Emplacement to Insertion
    Pass std::launch::async if Asynchronicity is Essential
    Minimize use of Weak Atomics
    Assume that move operations are neither present nor cheap
    Prefer Lambdas over Variadic Arguments to Threading Functions
    Be Wary of Oversubscription
    Pass by Value if You’ll Copy Your Parameter
    For Copyable Types, View Move as an Optimization of Copy
richelbilderbeek commented 7 years ago

Need his book to do so better.