std::cout
is a stream (See
https://en.wikipedia.org/wiki/Stream_(computing) ).
Things that are written to a stream leave your control as soon as they're consumed, so removing things from that stream just doesn't make sense.
Of course, a stream is not your terminal, and in an interactive context, it's the job of
the terminal (not of your program) to display the contents of that stream as it become available. Part of this job includes interpreting backspaces as it sees fit.
The point of this: if you need to control a terminal as if it was a screen, use a library like ncurses, or be judicious about it.
When you run your program interactively, doing
std::cout << "hello worls\bd\n";
prints
hello world
But if you redirect your program's output to a file (
./program > file), that
file will not merely contain
hello world
It will contain some extra bytes:
hello worls\bd\n
Which might change the meaning.
If your only concern is using this program interactively, probably Handy Andy has got the solution ;).