SFML community forums

Help => General => Topic started by: bendy on January 01, 2015, 08:50:36 pm

Title: Problem using an STL vector of sf::Vector2f s
Post by: bendy on January 01, 2015, 08:50:36 pm
Hi,
I am trying to load up an STL vector with sf::Vector2f s.

The problem is when I try to use an iterator over the vector. The iterator keeps on going past the stop condition.

                 std::vector<sf::Vector2f> points;
                 std::vector<sf::Vector2f>::iterator pIter;

                 for(pIter = points.begin(); pIter !=points.end(); pIter++) {
                 }   

And the real funny part is that sometimes it works and sometimes it doesn't.

Any suggestions?
Title: Re: Problem using an STL vector of sf::Vector2f s
Post by: Jesper Juhl on January 01, 2015, 09:15:45 pm
Based on just what you posted I'd say that something must be up with your tool-chain; but that's really just guessing.
The code snippet looks sane enough (old-school but sane).
Does the same thing happen if you use modern C++ - like:
for (auto& point : points) { ... }
?
Could you provide a comple, minimal, compilable example so other people can try to replicate your results?
Also, more details on OS and tool-chain would be good.
Title: Re: Problem using an STL vector of sf::Vector2f s
Post by: bendy on January 02, 2015, 02:25:21 am
It works perfectly. I had made an error in my algorithm elsewhere which was producing the mayhem.
Thanks everyone.