I want to create a sorted list without sorting it by the sum of digits of each number. Therefore I chose a set, but with a custom compare function. I did not use set before, but I've read a lot about it and I thought it'd be simple to use, but I don't really understand my error: Attempting to reference a deleted function
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <utility>
#include <queue>
#include <set>
#include <string>
#include <sstream>
using namespace std;
ifstream f("input.txt");
ofstream g("output.txt");
int sumCif(int x) {
if (x < 10) return x;
return x % 10 + sumCif(x / 10);
}
int main()
{
int x;
auto cmp = [](int a, int b) {
if (sumCif(a) < sumCif(b)) return true;
return a > b;
};
set<int, decltype(cmp)>s;
while (f >> x)
s.insert(x);
for (auto& i : s)
g << i << " ";
return 0;
}