← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/bug_1725724_ai_data into lp:widelands

 

Thanks for catching this one, Hasi!

We should never use the [] operator with maps going forward. It has side effects that one can forget about. This is how it inserts elements:

> If k matches the key of an element in the container, the function returns a reference to its mapped value.
>
> If k does not match the key of any element in the container, the function inserts a new element with that key and returns a reference to its mapped value.

And emplace:

> Inserts a new element in the unordered_map if its key is unique.

So, it the map was prefilled, the behavior changes.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug_1725724_ai_data/+merge/333681
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug_1725724_ai_data.


References