12.16

Bo Qian's YouTube Channel

Modern C++

1. C++ 11 Library: Unique Pointers

2. C++ 11: Resource Managing Class

3. C++ 11 Library: Tuple

4. C++ 11 Library: When to Use Tuple

 

Exceptional C++ Herb Sutter

1. Chapter 1. Uses and Abuses of vector

  Remember the difference between size/resize and capacity/reserve

  Be as const correct. In particular, use const_iterator when you are not modifying the contents of a container.

  Prefer comparing iterators with != not <. Because < works only with random-access iterators whereas != works with other iterator types too.

  Prefer using prefix -- and ++, instead of postfix

  Avoid needless recalculations.

  Prefer '\n' to endl. Because using endl forces the stream to flush its internal output buffers.

  Prefer reusing the standard library's copy and for_each instead of your own loops.

 

Effective C++ Scott Meyers

Chapter 1. Accustoming Yourself to C++

1. Item1: View C++ as a federation of languages.

2. Item2: Prefer consts, enums, and inlines to #defines

  String objects are generally preferable to their char* based progenitors

  As long as you don't take their address, you can declare class-specific constants that are static and of integral type without providing a definition.

  What is an "enum heck"?

  For simple constants, prefer const objects or enums to defines

  For function-like macros, prefer inline functions to #defines

3. Item3: Use const whenever possible.

  If the word const appears to the left of the *, what's pointed to is constant; if the word const appears to the right to the *, the pointer itself is constant.

  When should a function return const?

  Bitwise constness is C++'s definition of constness.

  Compilers enforce bitwise constness, but you should program using logical constness.

  When const and non-const member functions have essentially identical implementations, code duplication can be avoided by having the non-const version call the const version.

posted @ 2018-12-16 15:28  lefthook  阅读(119)  评论(0编辑  收藏  举报