Похожие чаты

Hi Could any one tell me what is wrong in my

code?

for(auto it = this->holder.end()-1;it >= this->holder.begin();--it){
if(*it == 0){
it = this->holder.erase(it);
}else{
break;
}
}
this->holder.shrink_to_fit();



it gets
double free or corruption (out)
Signal: SIGABRT (Aborted)
at line
this->holder.shrink_to_fit();

5 ответов

30 просмотров

https://stackoverflow.com/help/minimal-reproducible-example What is type of the holder ? Why you are using raw-loop instead of std::remove + std::erase or at least Reverse Iterators? What do you want to do?

I got used reverse iterator that's not much different from normal iterator type of holder is std::vector<unsigned int> and I use vector::erase i don't think there would be and difference between the method and std::erase I want to erase all 0 element from the end-1(last element) to begin and stop deleting when I got any other value

Prince Of Persia [field = CE,DM = BLOCK]
I got used reverse iterator that's not much differ...

Just use Reverse Iterators + std::remove + std::erase instead of those buggy loops. https://gist.githubusercontent.com/another-ghasem/565dfd86c6abaccd031e04be16963314/raw/5ef21487a63968e711d041d291a9cd7af8b8cec6/main.cc

Ghasem Ramezani
screenshot Just use Reverse Iterators + std::remove + std::er...

but I don't want to erase 0s in middle nor in beginning

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта