void set_val(stdext::hash_map<K,V,H,E,A> & ht,K const& key,V const &value=V()) { typedef stdext::hash_map<K,V,H,E,A> HT; stdextp::pair<typename HT::iterator,bool> r=ht.insert(typename HT::value_type(key,value)); if (!r.second) const_cast<V&>(r.first->second)=value; }
void add_new(stdext::hash_map<K,V,H,E,A> & ht,K const& key,V const &value=V()) { typedef stdext::hash_map<K,V,H,E,A> HT; stdextp::pair<typename HT::iterator,bool> r=ht.insert(typename HT::value_type(key,value)); if (!r.second) throw std::runtime_error("Key already existed in add_new(key,val)"); }