Closed arjenhiemstra closed 4 months ago
Hi @arjenhiemstra,
Thank you very much for reporting this issue.
I don't think it was a good idea to add the +=
operator to a unidirectional iterator because it gives the wrong impression that you can go backward with += -1
.
I prefer not to add it back in v7, so instead of fixing the code, I updated the documentation.
Best regards, Benoit
No prob! I understand that you want to drop it. Is it an idea/possible to support std::advance instead?
You should be able to define the +=
operator out of class.
Something along those lines (not tested):
JsonObject::iterator& operator+=(JsonObject::iterator& iterator, size_t offset) {
for (size_t i=0; i<offset; ++i)
++iterator;
return iterator;
}
If you do want to support std::advance
, you probably need to add more operators.
Describe the bug
Example code results in compiler error: no match for 'operator+='
Troubleshooter report
Here is the report generated by the ArduinoJson Troubleshooter:
Environment
Here is the environment that I used:
Reproduction
Here is a small snippet that reproduces the issue.
source: https://arduinojson.org/v7/api/jsonobject/begin_end/#get-object-member-by-index
Compiler output
If relevant, include the complete compiler output (i.e. not just the line that contains the error.)
Program output
If relevant, include the repro program output. n/a
Expected output:
Actual output: none