I was reading some docs about STL and it was written there that the end() function returns an iterator of the byte next to the last element of the container.
And I wonder, what if the container occupies the very last bytes of the whole available memory. What will happen then?
The C++ memory model guarantees that you can always form a pointer to the element after the last element of an array. If there is none, either the system won’t let you allocate an object at this location or it would wrap around. Also, note that this is a potential problem for arrays as other containers can use iterator types which deal with the past the end position in some other suitable form: they fully control how the increment operation work.