Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mchugh

simple STL question

This topic is 5636 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

just a quickie... is there a way to get an iterator to a certain position in a vector? for example
  

// whilst this gets an iterator to the first posisiton

vector<foo>::iterator bar;

bar = fooVector.begin();

// is there a way of doing something like this?


bar = fooVector[3];

  
i''ve been trying to use a
const_reference 
with the [] operators but have no success so far...

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Mchugh
hmmm, interesting - does my solution yield the same result? it seems to...

No, it doesn''t. The iterator of a vector is not guaranteed to be a pointer, it just happens to be in your compiler with its current STL implementation.

Share this post


Link to post
Share on other sites
quote:
Original post by Null and Void
[quote]Original post by Mchugh
hmmm, interesting - does my solution yield the same result? it seems to...

No, it doesn''t. The iterator of a vector is not guaranteed to be a pointer, it just happens to be in your compiler with its current STL implementation.



nice one, cheers

note: if theres any one from the UK here, theres a games show in ITV right now

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!