C++ Part 3

  • Why is using namespace std considered bad practice: StackOverflow
  • What is the difference between #include <filename> and #include "filename": StackOverflow
  • How do you set, clear, and toggle a single bit: StackOverflow
  • When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used: StackOverflow (a long answer post; try reading at least the top 5 voted answers)
  • What is the copy-and-swap idiom: StackOverflow
  • C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming: StackOverflow
  • Why is reading lines from stdin much slower in C++ than Python: StackOverflow
  • How can I profile C++ code running on Linux: StackOverflow
  • Name Mangling: StackOverflow
  • What is the effect of extern "C" in C++: StackOverflow
  • Why should I use a pointer rather than the object itself: StackOverflow

  • Why do we need a pure virtual destructor in C++: StackOverflow
  • Using mutex in two different classes: StackOverflow
  • Best practice: ordering of public/protected/private within the class definition: StackOverflow
  • Passing std::iterator parameters by value vs. by reference: StackOverflow
  • C++ namespaces and defining classes in separate files: StackOverflow
  • Does returning a temporary object create a temporary object in C++: StackOverflow
  • Copy Elision and RVO (Return Value Optimization): Wikipedia
  • Performance of dynamic_cast: StackOverflow
  • What is the iosfwd header: StackOverflow
  • Is std::vector so much slower than plain arrays: StackOverflow
  • Significance of ios_base::sync_with_stdio(false) and cin.tie(NULL) : StackOverflow
  • What is the purpose of the final keyword in C++11 for functions: StackOverflow
  • Why is processing a sorted-array faster than processing an unsorted-array: StackOverflow
  • Branch Prediction: Wikipedia
  • What are the differences between a pointer variable and a reference variable in C++: StackOverflow

  • Effective Modern C++ (Scott Meyers): Part 1
    1. Understand decltype
    2. Prefer auto to explicit type declarations.
    3. Use explicitly typed initializer idiom when auto deduces undesired types.
    4. Distinguish between () and {} when creating objects.
    5. Prefer nullptr to 0 and NULL.
    6. Prefer alias declarations to typdefs.
    7. Prefer scoped enums to unscoped enums.
    8. Prefer deleted functions to private undefined ones.
    9. Declare overriding functions override.
    10. Prefer const_iterators to iterators.
    11. Declare functions noexcept if they won't emit exceptions.
    12. Use constexpr whenever possible.
    13. Make const member functions thread-safe.
    14. Understand special member function generation.
    15. Use std::unique_ptr for exclusive ownership resource management.

  • Effective Modern C++ (Scott Meyers): Part 2
    1. Use std::shared_ptr for shared ownership resource management.
    2. Use std::weak_ptr for shared_ptr like pointers that can dangle.
    3. Prefer std::make_unique and std::make_shared to direct use of new.
    4. When using Pimpl idiom, define special member functions in the implementation file.
    5. Understand std::move and std::forward.
    6. Distinguish universal references from r-value references.
    7. Use std::move on r-value references, std::forward on universal references.
    8. Avoid overloading on universal references.
    9. Familiarize yourself with alternatives to overloading on universal references.
    10. Understand reference collapsing.
    11. Assume move operations are not present, not cheap and not used.
    12. Familiarize yourself with perfect-forwarding special cases.
    13. Avoid default capture modes in lambdas.
    14. Use init capture to move objects into closures.
    15. Use decltype on auto&& parameters to std::forward them.
    16. Prefer lambdas to std::bind.

  • Effective Modern C++ (Scott Meyers): Part 3
    1. Prefer task-based programming to thread-based.
    2. Specify launch::async if asynchronicity is essential.
    3. Make std::threads unjoinable on all paths.
    4. Use std::atomic for concurrency, volatile for special memory.
    5. Consider pass by value for copyable parameters that are cheap to move and always copied.
    6. Consider emplacement instead of insertion.