The whole point of the C ++ algorithm and container design is that the algorithms are - as far as possible - agnostic of the container.
So the same algorithm works that works on vectors! - line by line.
std::sort(str.begin(), str.end());
str.erase(std::unique(str.begin(), str.end()), str.end());
C - , erase , , ( begin end -, youd ).