
Dear all, Is there any specific reason why there is no operator[] const for boost::unordered_map? Or, is that only an oversight? TIA, --Hossein

On Sun, Sep 12, 2010 at 4:51 PM, Hossein Haeri
Dear all,
Is there any specific reason why there is no operator[] const for boost::unordered_map? Or, is that only an oversight?
Like map<>, operator[] inserts if the key doesn't already exist, so a const version won't work. You need to use find(). -- Cory Nelson http://int64.org

On 13 September 2010 14:03, Hossein Haeri
Cory,
Is there any specific reason why there is no operator[] const for boost::unordered_map? Or, is that only an oversight?
Like map<>, operator[] inserts if the key doesn't already exist, so a const version won't work. You need to use find().
I see. OK thanks.
There's also 'at' which is like 'operator[]' but throws an exception if it can't find the key. Daniel
participants (3)
-
Cory Nelson
-
Daniel James
-
Hossein Haeri