dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: problems iterating a std::map

  1. #1
    Sorin Gherman Guest

    problems iterating a std::map


    Is iterating a std::map any different than iterating a std::vector, for instance?
    I have problems iterating a map created in A.dll, from B.dll: the map::size()
    works fine, but map::end() isn't met anymore if I iterate like this:

    std::map<string, int> _map;

    for(std::map<string, int>::const_iterator it = _map.begin();
    it != _map.end();
    ++it)

    I am using the STL implementation that comes with VC++ 6.0

    Thanks in advance,
    Sorin

  2. #2
    Danny Kalev Guest

    Re: problems iterating a std::map



    Sorin Gherman wrote:
    >
    > Is iterating a std::map any different than iterating a std::vector, for instance?
    > I have problems iterating a map created in A.dll, from B.dll: the map::size()
    > works fine, but map::end() isn't met anymore if I iterate like this:
    >
    > std::map<string, int> _map;
    >
    > for(std::map<string, int>::const_iterator it = _map.begin();
    > it != _map.end();
    > ++it)


    This code should work. The end() member function should terminate the
    iteration once it equals the end of the map. I tested your code on C++
    Builder and it works fine. So there are two options: either you have a
    bug that causes the map internal buffers to run amuck, and consequently,
    end() doesn't return a reliable result, or you're using a buggy
    implementation of STL. Check the www.dinkumware.com site to see whether
    the STL code you're using is the culprit (I know VC++ 6 STL has bugs but
    the question is which SP and Library release version you're using).

    Danny

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center