[Bug libstdc++/39416] std::map::operator[] inserts a new item in RHS context

glyn at adgie dot f9 dot co dot uk gcc-bugzilla@gcc.gnu.org
Mon Mar 9 21:25:00 GMT 2009



------- Comment #2 from glyn at adgie dot f9 dot co dot uk  2009-03-09 21:25 -------
Thanks Paolo, I suspected that this was not a bug in libstdc++, but
standard-compliant behaviour.

It just seems so unexpected, when compared to other languages that have maps,
e.g. tables in Lua. It is also unexpected when compared to other STL
containers, e.g. std::vector. A bug in the standard, perhaps? I would have
thought that if other languages can implement the expected behaviour for
reading from an associative array, so should C++. Perhaps there is something in
the implementation of std::map that makes this impossible or inefficient, but I
must say, I cannot see why.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39416



More information about the Gcc-bugs mailing list