简体   繁体   English

C++中的键值存储

[英]Key-value storage in c++

Is there some key value Object in c++ besides STL::map?除了 STL::map 之外,c++ 中还有一些键值对象吗? I want to do something like this我想做这样的事情

bool addSalary( int salaryBonus , string name, storage &store ){

   if ( store[name] ){
      store[name]+=salaryBonus;
   }else{
      store[name]=saalaryBonus;
   }
return true;

}

But cant use stl::map , i cant find any build in "object" that would behave like key-value storage.但是不能使用 stl::map ,我无法在“对象”中找到任何类似于键值存储的构建。

I think you are trying to check if an entry exists.我认为您正在尝试检查条目是否存在。 This is possible with std::map .这可以通过std::map Here is how to do it:这是如何做到的:

store.find(name) != store.end()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM