jeudi 1 juin 2017

std::string::erase() segfaults when given an iterator with postfix decrement operator

I have a string-

std::string out;

and an iterator over that string-

std::string::iterator pos = out.begin();

if I do -

if(!out.empty() || pos > out.begin())
  out.erase(pos--);

It segfaults, saying something about the non existance of this file-

../sysdeps/x86_64/multiarch/memcpy-ssse3.S

What am I missing?

For some context, I'm implementing line editing with ncurses and this code defines behaviour when backspace is pressed.

Aucun commentaire:

Enregistrer un commentaire