On Saturday, February 18, 2012 21:54:52 Andrej Mitrovic wrote:
> Returning the default initializer of the value type when the key
> doesn't exist is a bad idea. Consider an integer, it's .init value is
> 0. If I want to check if a value of a key is zero I could easily end
> up with a silent bug:
>
> int[string] aa;
> aa["foobar"] = 5;
> if (aa["fobar"] == 0) { } // will always be true
> else { }
Agreed. The fact that C++ did something like this with std::map was one of its
big mistakes IMHO.
- Jonathan M Davis