Closed
Description
- Describe the feature in as much detail as possible.
I'm planning to make a template where it accepts any kind of maps. It need to have key_type and value_type just like the map containers in STL. I want also the nlohmann::json to be supported on that template helper functions. json::value_type is already there but the key_type is not yet. I checked the latest version 3.7.3 and it is still not yet there.
Here is one of my template functions:
template<typename M> inline bool HasKey(M const& p_map, typename M::key_type const& p_key) {
return p_map.find(p_key) != p_map.end();
}
- Include sample usage where appropriate.
using json = nlohmann::json;
std::map mData = getSomeMapData();
if(MyLib::HasKey(mData , "keyX")){
//found
}
json& jA = getSomeJSONData();
if(MyLib::HasKey(jA, "keyY")){
//found
}