How can I access to the reference of the .end() iterator when there is an assert that forces to avoid it?
Maybe the question could look a little bit silly but I have problems with iterators because of this, and of course commenting the assert is just a short term and dirty solution to the problem.
Could you provide an example?
We are doing a migration from rapidjson to your library:
We have a custom class that uses internally your library, so for that reason we create an iterator adaptor. During the construction of our begin() and end() methods we call to the operator*(), both to the end() and begin(), but the end() iterators give us the error due to the assert.
It is illegal to dereference an end iterator, from ANY container.
You can turn off assertions by defining the preprocessor macro NDEBUG, see https://en.cppreference.com/w/cpp/error/assert. But as @gregmarr described, you must never dereference a past-the-end iterator in the first place.
Thanks, I will do that, I close this, thanks
Most helpful comment
It is illegal to dereference an
enditerator, from ANY container.