Iterating over unequal unordered pairs in one collection
Also not really pretty, but perhaps a start

#include &lt;algorithm&gt;
#include &lt;iostream&gt;
#include &lt;list&gt;
using namespace std;

int main()
{
    list&lt;int&gt; lst = {1,2,3,4,5,6};

    auto a = lst.cbegin();
    int first = *a;
    auto output_pairs = [&amp;first](const int second){ cout &lt;&lt; " ("&lt;&lt;first&lt;&lt;','&lt;&lt;second&lt;&lt;')'; };
    while(++a != lst.cend())
    {
        for_each(a, lst.cend(), output_pairs);
        cout &lt;&lt; '\n';
        first = *a;
    }
    cout &lt;&lt; flush;
}


It's C++0x because I was too lazy to write a functor for that lambda and I don't know the Boost.Lambda syntax off the top of my head.