auto cmp = [](int a, int b) {return a > b;}; //somethings you want to do with your set set<int, decltype(cmp)> s(cmp);