原创 NSQ 單機測試(單個 topic)

nsq 環境搭建 官方文檔 官方文檔中文版 官方文檔中文版PDF nsq 虛擬機測試(單個 topic) 測試環境 object describe cpu 2 memory 8G nsqd count 1

原创 條款 16:成對使用 new 和 delete 是要採用相同形式

條款 16:成對使用 new 和 delete 時要採用相同形式 Use the same form in corresponding uses of new and delete. std::string * stringA

原创 條款 15:在資源管理類中提供對原始資源的訪問

條款 15:在資源管理類中提供對原始資源的訪問 Provide access to raw resources in resource-managing classes. int dausHeld(const Invectme

原创 條款 13:以對象管理資源

條款 13:以對象管理資源 Use objects to manage resources. 依賴人爲的 delete 掉 new 出來的資源,基本是行不通的,忘記、過早 return、代碼修改等都會引起資源沒有被正確釋放導致

原创 條款 14:在資源管理類中小心 copying 行爲

條款 14:在資源管理類中小心 copying 行爲 Think carefully about copying behavior in resource-managing classes. class Lock { publ

原创 條款 17:以獨立語句將 newed 對象置入智能指針

條款 17:以獨立語句將 newed 對象置入智能指針 Store newed objects in smart pointers in stanalone statements. processWidget(std::sha

原创 條款 10:令 operator= 返回一個 reference to *this

條款 10:令 operator= 返回一個 reference to *this Have assignment operators return a reference to *this. 爲了下列實現“連鎖賦值”,需要令

原创 條款 12:複製對象時勿忘其每一個成分

條款 12:複製對象時勿忘其每一個成分 Copy all parts of an object. 當 class 添加新變量時,所有 copy、copy assignment 函數需要處理這些成員變量的複製 存在繼承關係時,

原创 條款 11:在 operator= 中處理“自我賦值”

條款 11:在 operator= 中處理“自我賦值” Handle assignment to self in operator=. 什麼是自我賦值 “自我賦值”發生在對象賦值給自己時 class Widget { ...

原创 條款 09:絕不在構造和析構過程中調用 virtual 函數

條款 09:絕不在構造和析構過程中調用 virtual 函數 Never call virtual functions during construction or destruction. 假設子類各有不同的記錄日誌實現,有

原创 條款 08:別讓異常逃離析構函數

條款 08:別讓異常逃離析構函數 Prevent exceptions from leaving destructors. 如果析構函數吐出異常,可能導致不明確行爲,如下面 vector 銷燬時會調用所有元素的析構函數,這會導

原创 條款 05:瞭解 C++ 默默編寫並調用了哪些函數

條款 05:瞭解 C++ 默默編寫並調用了哪些函數 Know what functions C++ silently writes and calls. C++ 編譯器會自動創建哪些函數 對於一個空類,編譯器可能默默生成下面四

原创 條款 04:確定對象被使用前已被初始化

條款 04:確定對象被使用前已被初始化 Make sure that objects are initialized before thre’re used. c++ 不保證下面語境初始化 int x; class Poin

原创 條款 03:儘可能使用 const

條款 03:儘可能使用 const Use const whenever possible const 修飾指針和常量 char greeting[] = "Hello"; char* p = greeting; //

原创 條款 06:若不想使用編譯器自動生成的函數,就該明確拒絕

條款 06:若不想使用編譯器自動生成的函數,就該明確拒絕 Explicitly disallowa the use of compiler-generated functions you do not want. 如何阻止編譯