Boost logo

Boost :

From: Felipe Magno de Almeida (felipe.almeida_at_[hidden])
Date: 2005-03-17 17:05:34

Ive modified the ptr_map_adapter in the operator[]
to be:
const_reference operator[]( const key_type& key ) const
     //return lookup( key );
     iterator i = find( key );
     if( i != end() )
         return *i;
     else {
         i = const_cast<ptr_map_adapter_base*>(this)
             ->insert(begin(), key,
         return *i;
and the non-const just dont have the const_cast, but this way I think
value_type is default-constructed and then copy-constructed isnt? well,
this isnt very efficient, but to my needs it is already better.

Thorsten Ottosen wrote:
> Hi Felipe,
> "Felipe Magno de Almeida" <felipe.almeida_at_[hidden]> wrote in message
> | Hi.
> |
> | I dont see why ptr_map throws in operator[], I think it should have the
> | same behavior of std::map and return a default constructed object in
> | case it doesnt find the key.
> | Anyway, it is just a opinion
> Hm..yeah...I guess you can use
> "foo" );
> if you want the exception to be thrown. I think you're right
> it should call insert a heap-allocated object.
> I will change this for the post-review. In the meantime, you can make
> a new function in ptr_map_adapter using lookup()
> as a template to get the behavior you need.
> .
> | Im using ptr_map in production code and
> I'm glad to hear that.
> -Thorsten
> _______________________________________________
> Unsubscribe & other changes:

    Felipe Magno de Almeida
    UIN: 2113442
     email: felipe.almeida at ic unicamp br, felipe.m.almeida at gmail 
com, felipe at synergy com
I am a C, modern C++, MFC, ODBC, Windows Services, MAPI developer
from synergy, and Computer Science student from State
University of Campinas(UNICAMP).
To know more about:
current work:

Boost list run by bdawes at, gregod at, cpdaniel at, john at