Boost logo

Boost Users :

Subject: Re: [Boost-users] [Unordered] No operator[] const?
From: Daniel James (dnljms_at_[hidden])
Date: 2010-09-13 10:17:20


On 13 September 2010 14:03, Hossein Haeri <powerprogman_at_[hidden]> wrote:
> 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net