I am trying to update an atomic
variable through different threads and getting this error. This is my code.
class counter {
public:
std::atomic<int> done;
bool fn_write (int size) const {
static int count = 0;
if (count == size) {
done++;
count = 0;
return false;
} else {
count++;
return true;
}
}
};
int main() {
counter c1;
for (int i=0; i<50; i++) {
while (! c1.fn_write(10)) ;
}
}
I am getting the following error in line 8 done++
.
error: no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive]
Aucun commentaire:
Enregistrer un commentaire