Boost logo

Boost Users :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2004-12-01 09:08:10


"Martin Wartens" <martin.wartens_at_[hidden]> wrote in message
news:380-2200411230224347494_at_my-mail.ch...
> Hi all,
> I am trying to disguise a std container non-const iterator as a
> const_iterator. My guess is that iterator_adaptor could be useful for
this,
> but I can't figure it out myself.
>
> I am trying to solve an old problem with the standard library, which is
> that you can't convert a const_iterator into an iterator. [There are two
> "solutions" to that problem, one uses distance and is expensive, the other
> one does a brutal conversion on bitlevel which breaks for several std
> implementations.]

 A third solution?: (untested)

const_iterator_type wrapper::erase( const_iterator_type aItr )
{
    thismaptype::iterator lItr = thismap.find( aItr->first );

    if( lItr == thismap.end() ) throw something;

    return thismap.erase( lItr );
}

Jeff Flinn


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net