Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-03-18 03:19:22


"Felipe Magno de Almeida" <felipe.almeida_at_[hidden]> wrote in message
news:423A06C2.6020404_at_ic.unicamp.br...
| sorry, it's just wrong.
|
| Felipe Magno de Almeida wrote:
| > 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,
| > CloneAllocator::allocate_clone(value_type()));
| > return *i;
| > }
| > }

Try

     iterator i = this->find( key )
            if( i != this->end() )
                return *i;
            else
            {
                auto_type ptr( new value_type );
                this->c_private()[ key ] = ptr.get(); // strong
                return *ptr.release(); // nothrow
            }

-Thorsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk