Patchwork [v3] Add operator[](Key&&) to profile-mode unordered_map

login
register
mail settings
Submitter Paolo Carlini
Date Nov. 7, 2010, 6:58 p.m.
Message ID <4CD6F6E4.6080806@oracle.com>
Download mbox | patch
Permalink /patch/70368/
State New
Headers show

Comments

Paolo Carlini - Nov. 7, 2010, 6:58 p.m.
Hi,

tested x86_64-linux profile-mode, committed to mainline.

Paolo.

////////////////////////
2010-11-07  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/profile/unordered_map (unordered_map<>::operator[](_Key&&)):
	Add.

Patch

Index: include/profile/unordered_map
===================================================================
--- include/profile/unordered_map	(revision 166416)
+++ include/profile/unordered_map	(working copy)
@@ -232,18 +232,28 @@ 
         _Base::insert(__first, __last);
         _M_profile_resize(__old_size, _Base::bucket_count()); 
       }
-     
-      // operator []
+
+      // operator[]
       mapped_type&
-      operator[](const _Key& _k)
+      operator[](const _Key& __k)
       {
         size_type __old_size =  _Base::bucket_count();
-        mapped_type& __res = _M_base()[_k];
+        mapped_type& __res = _M_base()[__k];
         size_type __new_size =  _Base::bucket_count();
         _M_profile_resize(__old_size, _Base::bucket_count()); 
         return __res;
-      }   
+      }
 
+      mapped_type&
+      operator[](_Key&& __k)
+      {
+        size_type __old_size =  _Base::bucket_count();
+        mapped_type& __res = _M_base()[std::move(__k)];
+        size_type __new_size =  _Base::bucket_count();
+        _M_profile_resize(__old_size, _Base::bucket_count()); 
+        return __res;
+      }
+
       void
       swap(unordered_map& __x)
       { _Base::swap(__x); }