Jump to content
  • Advertisement
Sign in to follow this  
3dcgmodeling

advance not work

This topic is 4252 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

std::vector<int> v; std::advance(v.begin(),v.end()); compile tell me: error C2664: 'advance' : cannot convert parameter 1 from 'char ** ' to 'char **& ' A reference that is not to 'const' cannot be bound to a non-lvalue it is strang. how to solve it?

Share this post


Link to post
Share on other sites
Advertisement
v.end() returns an iterator. std::advance takes integral type as its 2nd paramater not an iterator

std::vector<int> v;
v.push_back(5);
v.push_back(67);
std::advance((v.begin()),1);


works here.

if you are hoping to increment the iterator returned by begin(), you must realize that you are getting a copy back from this fn. So the above code really does nothing as the result is lost right after the function call.

Docs that might help.
Vector
Advance

Share this post


Link to post
Share on other sites
You are not using the function correctly. The first parameter is an iterator whose value you want to change. The second parameter is an integer value that tells how many times to increment the first parameter.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!