strange std::map behavior
Why insert a new element and return a default value? Why not just raise an exception here? This really seems bad.
map::operator public member function
T& operator ( const key_type& x );
If x matches the key of an element in the container, the function returns a reference to its mapped value.
If x 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. Notice that this always increases the map size by one, even if no mapped value is assigned to the element (the element is constructed using its default constructor).
On a side note: Ditto behavior in Qt's QMap as well. Why such practice?