You could std::sort and run std::unique on the elements before getting the combinations.
That is actually too restrictive. In my example (3 of "ABBCCCDD"), using std::unique and your code would only provide 4 values:

B C D
A C D
A B D
A B C

and is missing values such as:

A B B
C C C
B B D
B D D
(and there are six others)

- Kevin

P.S. Don't get me wrong. I think your code is great.... I've kept it around b/c it is very useful. It just isn't meeting my needs for one particular problem.