E
Eric Lilja
Is there something "elegant" in the standard library I can use to
perform a "shifted insert" in a std::string? Let me examplify what I
mean with shifted insert.
Say I have:
std::string foo = "abc";
std::string shifted_foo = shifted_insert(foo, 'd');
shifted_foo should after the shifted_insert() equal "dab".
The char 'd' is inserted first, pushing everything up one index but
the size of the string should remain the same so in effect the last
char 'c' is pushed off the edge.
Doing this manually is relatively easy but I wanted to check if I'm
missing out on something in the standard library.
Thanks for any replies.
- Eric
perform a "shifted insert" in a std::string? Let me examplify what I
mean with shifted insert.
Say I have:
std::string foo = "abc";
std::string shifted_foo = shifted_insert(foo, 'd');
shifted_foo should after the shifted_insert() equal "dab".
The char 'd' is inserted first, pushing everything up one index but
the size of the string should remain the same so in effect the last
char 'c' is pushed off the edge.
Doing this manually is relatively easy but I wanted to check if I'm
missing out on something in the standard library.
Thanks for any replies.
- Eric