From be3c93b01193a0811d38678c123ea3345af73e98 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sun, 7 Nov 2010 18:56:56 +0000 Subject: [PATCH] unordered_map (unordered_map<>::operator[](_Key&&)): Add. 2010-11-07 Paolo Carlini * include/profile/unordered_map (unordered_map<>::operator[](_Key&&)): Add. From-SVN: r166420 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/profile/unordered_map | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1bc5dfab23b..d9156b1b380 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2010-11-07 Paolo Carlini + + * include/profile/unordered_map (unordered_map<>::operator[](_Key&&)): + Add. + 2010-11-07 Paolo Carlini * include/profile/bitset (bitset<>::bitset(), bitset<>:: diff --git a/libstdc++-v3/include/profile/unordered_map b/libstdc++-v3/include/profile/unordered_map index 18563d87508..49345cc53ae 100644 --- a/libstdc++-v3/include/profile/unordered_map +++ b/libstdc++-v3/include/profile/unordered_map @@ -232,17 +232,27 @@ namespace __profile _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)