一. 開發(fā)環(huán)境環(huán)境
- 基本環(huán)境設(shè)置
gcc -v 查看編譯器版本
http://www.runoob.com/cplusplus/cpp-environment-setup.html - CMake 編譯器/鏈接器
https://blog.csdn.net/xierhacker/article/details/79445339
cpplint ? - 基于VSCode
https://code.visualstudio.com/docs/languages/cpp
【C/C++】extension. This is an official Microsoft extension.
【CMake】extension.
【CMake Tools】extension. This enables usage of a set of CMake commands from inside VS Code.
【Native Debug】.
C++ libraries 绎秒?
.vscode
.cmaketools.json # CMake: Build
.c_cpp_properties.json # C/Cpp: Edit Configurations
.launch.json # Debug: Open launch.json 【C++ (GDB/LLDB)】
https://lain.run/tutorials/Boost-and-Visual-Studio-Code/
https://medium.com/audelabs/c-development-using-visual-studio-code-cmake-and-lldb-d0f13d38c563
- 基于VIM席揽?
二、基礎(chǔ)
-
基礎(chǔ)語法(指針/引用是重點)
動態(tài)內(nèi)存分配/釋放 - Google C++ Style Guide
-
基礎(chǔ)類庫STL
leveldb源代碼中使用std的統(tǒng)計
std::x | count |
---|---|
std::string | 729 |
std::vector | 101 |
std::set | 15 |
std::string::npos | 9 |
std::numeric_limits | 7 |
std::make_pair | 7 |
std::move | 7 |
std::map | 5 |
std::memory_order_relaxed | 5 |
std::pair | 4 |
std::atomic | 4 |
std::min | 4 |
std::sort | 3 |
std::FILE | 3 |
std::mutex | 2 |
std::string::size_type | 2 |
std::fwrite | 2 |
std::strerror | 2 |
std::memcpy | 2 |
std::thread | 2 |
std::aligned_storage | 2 |
std::deque | 2 |
std::memory_order::memory_order_relaxed | 2 |
std::abort | 2 |
std::fflush | 1 |
std::condition_variable | 1 |
std::fclose | 1 |
std::memset | 1 |
std::stringstream | 1 |
std::upper_bound | 1 |
std::unique_lock | 1 |
std::memory_order_seq_cst | 1 |
std::forward | 1 |
std::queue | 1 |
std::this_thread::get_id | 1 |
std::time_t | 1 |
std::string::reverse_iterator | 1 |
std::vsnprintf | 1 |
std::snprintf | 1 |
std::rename | 1 |
std::getenv | 1 |
std::atomic_thread_fence | 1 |
std::fopen | 1 |
std::tm | 1 |
std::memory_order_release | 1 |
std::va_list | 1 |
std::ostringstream | 1 |
std::max | 1 |
std::adopt_lock | 1 |
std::memory_order_acquire | 1 |
std::swap | 1 |
- Boost類庫
https://futucocoa.github.io/2017-01-06-macOSBoostInstallGuide/
brew install boost
/usr/local/Cellar/boost/1.67.0_1
boost::lexical_cast 2
boost::split 1
boost::shared_ptr 1
boost::is_any_of 1
boost::static_pointer_cast 1
boost::random::mt 1
boost::random::discrete_distribution 1 -
Google Protocol Buffers
https://developers.google.com/protocol-buffers/
https://www.ibm.com/developerworks/cn/linux/l-cn-gpb/index.html
which protobuf
conda install protobuf
protoc --version
cmake+pb
三倦踢、應(yīng)用
https://github.com/fffaraz/awesome-cpp
- 日志庫
- 配置文件磁浇?
- 讀寫redis
- 讀寫mysql
- http/rpc請求
- pb/json/xml處理斋陪?
四、高級
GDB
出core后如何調(diào)試
內(nèi)存泄露置吓,cpu狂漲的原因追查
五无虚、優(yōu)秀的開源項目
sqlite
redis
nginx
六、其他
union,聯(lián)合體衍锚?
make -j 8 #多線程編譯
符號:
::
<<
->
&
.
標(biāo)識符:
https://www.runoob.com/w3cnote/cpp-keyword-intro.html
auto友题,聲明變量時根據(jù)初始化表達式自動推斷該變量的類型、聲明函數(shù)時函數(shù)返回值的占位符
static戴质,在程序的生命周期內(nèi)保持局部變量的存在度宦,而不需要在每次它進入和離開作用域時進行創(chuàng)建和銷毀
const_cast
dynamic_cast
static_cast
reinterpret_cast
delete
explicit
export
extern
friend
mutable
operator
register,用于定義存儲在寄存器中而不是 RAM 中的局部變量
template
this
typedef #為一個已有的類型取一個新的名字
typeid
typename
union
virtual
volatile
wchar_t
三字符組告匠, 不常見戈抄?
數(shù)據(jù)結(jié)構(gòu)?
std::vector<uint64_t>
std::map<uint64_t, int>
std::unordered_map<uint64_t, int64_t>
std::pair<std::string, float>
std::max
std::rand()
std::shared_ptr
std::accumulate
boost::random::discrete_distribution<>
boost::random::mt19937 gen((unsigned int) std::time(NULL));
boost::split
boost::is_any_of(",")
boost::lexical_cast<uint64_t>
std::make_pair
函數(shù)參數(shù):傳值調(diào)用
指針調(diào)用
| 引用調(diào)用 |
c++指針
引用
三后专、常用類庫
std::unordered_map
std::shared_ptr
std::string
c++ 使用pb?
多線程編程呛凶?
操作pb?
四行贪、常見問題漾稀?
1.# error passing 'const' as 'this' argument
簡單語法了解
常用類庫
virtual, 接口定義?Base的虛擬函數(shù)建瘫,子類可以重寫虛擬函數(shù)崭捍。
typedef,
類型轉(zhuǎn)換:str 轉(zhuǎn)int 等