Jump to content
• Advertisement

Public Group

advance not work

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

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

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

Share on other sites

• Advertisement

Announcements

• Advertisement
• Popular Tags

• Advertisement

• 17
• 11
• 12
• 9
• 49
• Forum Statistics

• Total Topics
631395
• Total Posts
2999757
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!