⚡高效地使用std::map
map<string, int> m; const char K[] = "key"; void fn1 () { auto p = m.insert({K, 0}); ++(p.first->second); } void fn2 () { auto it = m.find(K); if (it != m.end()) ++(it->second); }
gcc version 12.2.0 (Debian 12.2.0-14+deb12u1) 不用加-std

加了-std=c++03可以编译通不过。:-)

浙公网安备 33010602011771号