From: Paolo Carlini Date: Sun, 7 Nov 2010 18:56:56 +0000 (+0000) Subject: unordered_map (unordered_map<>::operator[](_Key&&)): Add. X-Git-Tag: releases/gcc-4.6.0~2843 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=be3c93b01193a0811d38678c123ea3345af73e98;p=thirdparty%2Fgcc.git unordered_map (unordered_map<>::operator[](_Key&&)): Add. 2010-11-07 Paolo Carlini * include/profile/unordered_map (unordered_map<>::operator[](_Key&&)): Add. From-SVN: r166420 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1bc5dfab23b4..d9156b1b3806 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 18563d875082..49345cc53aef 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) + { + size_type __old_size = _Base::bucket_count(); + 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[](const _Key& _k) + operator[](_Key&& __k) { size_type __old_size = _Base::bucket_count(); - mapped_type& __res = _M_base()[_k]; + 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)