原创 C++核心準則R.33: 表達函數會重置widget時,使用unique_ptr(widget)& 作參數
R.33: Take a unique_ptr<widget>& parameter to express that a function reseats the widget R.33: 表達函數會重置widget時,使用unique
原创 C++核心準則ES.10:每次只定義一個名稱
ES.10: Declare one name (only) per declaration ES.10:每次只定義一個名稱 Reason(原因) One declaration per line increases readabil
原创 C++核心準則R.37: 不要使用從破損的智能指針 獲取的指針或引用
R.37: Do not pass a pointer or reference obtained from an aliased smart pointer R.37: 不要使用從破損的智能指針獲取的指針或引用 Reason(原因)
原创 C++核心準則ES.12:不要在嵌套作用域中重複使用同樣的名稱
ES.12: Do not reuse names in nested scopes ES.12: 不要在嵌套作用域中重複使用同樣的名稱 Reason(原因) It is easy to get confused about whic
原创 C++核心準則ES.9:避免所有字母都大寫的名稱
ES.9: Avoid ALL_CAPS names ES.9:避免所有字母都大寫的名稱 Reason(原因) Such names are commonly used for macros. Thus, ALL_CAPS name
原创 C++核心準則ES.5: 儘量壓縮作用域
ES.5: Keep scopes small ES.5: 儘量壓縮作用域 Reason(原因) Readability. Minimize resource retention. Avoid accidental misuse of
原创 C++核心準則ES.11:使用auto避免多餘的類型名重複
ES.11: Use auto to avoid redundant repetition of type names ES.11:使用auto避免多餘的類型名重複 Reason(原因) Simple repetition is t
原创 C++核心準則ES.7: 通用和局部的名稱應該簡短,特殊和非局部的名稱 應該較長
ES.7: Keep common and local names short, and keep uncommon and non-local names longer ES.7: 通用和局部的名稱應該簡短,特殊和非局部的名稱應該較長。
原创 C++核心準則R.24: 使用std::weak_ptr打破share_ptrs造成的循環
R.24: Use std::weak_ptr to break cycles of shared_ptrs R.24: 使用std::weak_ptr打破share_ptrs造成的循環 Reason(原因) shared_ptr's
原创 C++核心準則R.20: 使用unique_ptr或者shared_ptr表示所有權
R.20: Use unique_ptr or shared_ptr to represent ownership R.20: 使用unique_ptr或者shared_ptr表示所有權 Reason(原因) They can pre
原创 C++核心準則R.21:不需要共享所有權時應該使用unique_ptr而不是 shared_ptr
R.21: Prefer unique_ptr over shared_ptr unless you need to share ownership R.21:不需要共享所有權時應該使用unique_ptr而不是shared_ptr Re
原创 C++核心準則R.32: 通過 unique_ptr(widget)類型參數表示函數試圖獲取widget的所有權
R.32: Take a unique_ptr<widget> parameter to express that a function assumes ownership of a widget R.32: 通過unique_ptr<w
原创 C++核心準則R.30: 只有在包含明確的生命週期語義時使用智能指針作參數
R.30: Take smart pointers as parameters only to explicitly express lifetime semantics R.30: 只有在包含明確的生命週期語義時使用智能指針作參數
原创 C++核心準則R.31:如果需要實現標準庫以外的智能指針,遵照標準庫中的基本模式
R.31: If you have non-std smart pointers, follow the basic pattern from std R.31:如果需要實現標準庫以外的智能指針,遵照標準庫中的基本模式 Reason(
原创 C++核心準則R.22: 使用make_shared()構建共享shared_ptr
R.22: Use make_shared() to make shared_ptrs R.22: 使用make_shared()構建共享shared_ptr Reason(原因) If you first make an objec