stl map erase

This is a discussion on stl map erase within the C++ Programming forums, part of the General Programming Boards category; I have this function which works fine in visual studio: btw this is code for a c++ stl map, where ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    38

    stl map erase

    I have this function which works fine in visual studio:

    btw this is code for a c++ stl map, where map is Life and the iterator is di.

    Code:
    void structure::deletion_process()
    {
    	for (di = Life.begin(); di != Life.end(); /* nothing here */)
    	{
    		if (di->second.getDelete())
    		{
    		  di =Life.erase(di);
    		}
    		else
    		{
    		   ++di;
    		}
    	}
    }
    but when i run it in linux i get this error:
    error: no match for operator=

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,752
    map::erase() does not return an iterator. It returns nothing unless you call the version that erases all occurrences of a specific value, which returns a count. You've been using an implementation of erase() specific to visual studio, apparently.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 47
    Last Post: 07-13-2010, 08:22 PM
  2. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 09:32 AM
  3. STL List Erase
    By shamgar00 in forum C++ Programming
    Replies: 7
    Last Post: 10-22-2007, 03:58 PM
  4. STL Map Object
    By nomes in forum C++ Programming
    Replies: 6
    Last Post: 09-11-2003, 02:51 PM
  5. Searching STL Map Inside STL Map Object :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 11-14-2002, 09:11 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21