Skip to content

Commit

Permalink
4436
Browse files Browse the repository at this point in the history
  • Loading branch information
akkartik committed Jul 27, 2018
1 parent 29426e5 commit ab2ee1d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions subx/001help.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,18 @@ int feenableexcept(unsigned int excepts) {
// from http://stackoverflow.com/questions/152643/idiomatic-c-for-reading-from-a-const-map
template<typename T> typename T::mapped_type& get(T& map, typename T::key_type const& key) {
typename T::iterator iter(map.find(key));
assert(iter != map.end());
if (iter == map.end()) {
cerr << "get couldn't find key '" << key << "'\n";
assert(iter != map.end());
}
return iter->second;
}
template<typename T> typename T::mapped_type const& get(const T& map, typename T::key_type const& key) {
typename T::const_iterator iter(map.find(key));
assert(iter != map.end());
if (iter == map.end()) {
cerr << "get couldn't find key '" << key << "'\n";
assert(iter != map.end());
}
return iter->second;
}
template<typename T> typename T::mapped_type const& put(T& map, typename T::key_type const& key, typename T::mapped_type const& value) {
Expand Down

0 comments on commit ab2ee1d

Please sign in to comment.