This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: map
- To: jochen at uni-duesseldorf dot de
- Subject: Re: map
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 26 Sep 1998 01:17:53 +-300
- Cc: egcs mailing list <egcs at cygnus dot com>
- References: <9809251452180G.09832@bacchus.pc1.uni-duesseldorf.de>
Jochen Kuepper <jochen@uni-duesseldorf.de> writes:
> I am missing the following function from the class map ( as of egcs-1.1 )
> const T& operator[](const key_type& k) const;
> In the class header file (stl_map.h) there is only
> T& operator[](const key_type& k);
As the standard mandates. The problem is that operator[] will insert
a value for the given key_type if none exists. I'm of the opinion
that a const member function should have been defined, that would
throw an exception if the key were not present in the map already, but
the members of the standard committee thought otherwise :-(
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil