c++11 - iterator in C++ stl list not pointing to the middle of a list.. how would I solve this? -


i trying make miditer point middle of list, keep getting error when try this.. using stl list, got ideas this?

    std::list<playernode>::iterator startiter, miditer, enditer;      startiter = wall_list_.begin();      miditer = psnake_parts_.begin() + new_size_; // trying point half of list.      enditer = psnake_parts_.end();       if (x_ == poison_.getx() && y_ == poison_.gety()){  //trying make list remove half.       wall_list_.splice (startiter, psnake_parts_, miditer, enditer);       } 

std::list iterators bidirectional iterators , can incremented , decremented. need container std::vector if want random access iterator supports addition , subtraction.

example clarification:

std::list<int> mylist = somefunctiontofillmylistwithdata(); auto listiter = mylist.begin();  // can because list iterators bidirectional listiter++; listiter--;  // cannot because not random access auto someotherpointiter = listiter + 5; 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -