I'm a bit baffled by something I'm seeing in a class defined in the ESPAsyncWebServer library. The AsyncWebSocketMessageBuffer class has increment and decrement operators defined that simply increment and decrement a uint32_t member variable, _count. But the operators are defined like this:
void operator ++(int i) { _count++; }
void operator --(int i) { if (_count > 0) { _count--; } ; }
These two line cause a boat-load of "unused parameter" warnings.
Yet, if I change the operator definitions thusly:
void operator ++() { _count++; }
void operator --() { if (_count > 0) { _count--; } ; }
Then when the code attempts to invoke the operators:
AsyncWebSocketMessageBuffer * _WSbuffer;
...
(*_WSbuffer)++;
I get errors that there are no increment or decrement operators defined for class AsyncWebSocketMessageBuffer!
I can, of course, simply ignore the warnings, but I'd rather get rid of them, if possible, as there are a LOT of them.
I really don't understand the operator definitions passing integer arguments. My understanding is those operators can take either no argument, or a reference to an object of the given class. But these are passing an int, when the class is a complex class. Why is there no error on the definitions? Why does removing the argument result in the operators being undefined?
I'm confused....
Regards,
Ray L.
AsyncWebSocket.cpp (33 KB)
AsyncWebSocket.h (12.5 KB)