about summary refs log tree commit diff stats
path: root/001help.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-11-19 03:24:54 -0800
committerKartik K. Agaram <vc@akkartik.com>2017-11-19 03:24:54 -0800
commit82f3c320eac140067e1510786fad52c72574348e (patch)
tree351be1c601e7501b488776f480991c19a0f2d618 /001help.cc
parentbc4d02c8486e328e73b54d51a452885f1648db68 (diff)
downloadmu-82f3c320eac140067e1510786fad52c72574348e.tar.gz
4129
map::operator[](k) is indeed equivalent to (*((this->insert(make_pair(k,mapped_type()))).first)).second
Diffstat (limited to '001help.cc')
-rw-r--r--001help.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/001help.cc b/001help.cc
index 188862b0..a75657a8 100644
--- a/001help.cc
+++ b/001help.cc
@@ -220,8 +220,8 @@ template<typename T> typename T::mapped_type const& get(const T& map, typename T
 }
 template<typename T> typename T::mapped_type const& put(T& map, typename T::key_type const& key, typename T::mapped_type const& value) {
   // requires value to have a zero-arg (default) constructor
-  map[key] = value;
-  return map[key];
+  (*((map.insert(std::make_pair(key, typename T::mapped_type()))).first)).second = value;
+  return (*((map.insert(std::make_pair(key, typename T::mapped_type()))).first)).second;
 }
 template<typename T> bool contains_key(T& map, typename T::key_type const& key) {
   return map.find(key) != map.end();