Boost logo

Boost Users :

From: Bill Buklis (boostuser_at_[hidden])
Date: 2006-02-16 18:58:28


The following code does not successfully compile:

boost::ptr_map<int,int> testmap;

testmap.erase(5);

The compiler (MSVC 7.1) complains that the identifier "find" is unknown
inside the erase function (see below). The class does have a find function
as "testmap.find(5)" compiles as expected. I expect it's a mismatch with the
embedded classes.

Taken directly from associate_ptr_container.hpp:

size_type erase( const key_type& x ) // nothrow
{
    BOOST_ASSERT( !this->empty() );
    iterator i = find( x ); // ERROR ON THIS LINE
    if( i == this->end() )
        return 0;
    this->remove( i );
    return this->c_private().erase( i.base() );
}

The following workaround does work at least, but the above should also,
shouldn't it?

        testmap.erase( testmap.find(5) );

-- Bill Buklis --


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