Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem using an STL vector of sf::Vector2f s  (Read 1060 times)

0 Members and 1 Guest are viewing this topic.

bendy

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problem using an STL vector of sf::Vector2f s
« 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?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Problem using an STL vector of sf::Vector2f s
« Reply #1 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.

bendy

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Problem using an STL vector of sf::Vector2f s
« Reply #2 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.

 

anything