使用两级循环:
// Loop over all members.
for (set<string>::iterator j = s.begin(); j != s.end(); ++j)
{
// Loop over all members up to, but excluding, the current outer-loop member.
for (set<string>::iterator i = s.begin(); i != j; ++i)
{
do_something_with(*i, *j);
}
}