diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-11-19 03:24:54 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-11-19 03:24:54 -0800 |
commit | 82f3c320eac140067e1510786fad52c72574348e (patch) | |
tree | 351be1c601e7501b488776f480991c19a0f2d618 /001help.cc | |
parent | bc4d02c8486e328e73b54d51a452885f1648db68 (diff) | |
download | mu-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.cc | 4 |
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(); |