Reputation: 7923
The cppreference wording on front
and back
is surprisingly (at least for me) asymmetric.
Calling
front
on an empty container is undefined.
Calling
back
on an empty container causes undefined behavior.
I know I am supposed to ask only one question, but still,
Upvotes: 0
Views: 131
Reputation: 1160
In C++, there is no difference between "undefined" and "undefined behavior." Both terms refer to the same concept: a situation in which the standard does not specify the expected outcome of a certain operation.
Upvotes: 2
Reputation: 1
What is the difference between is undefined and causes undefined behavior?
They have the same meaning here.
Why it is different?,
Most likely because the page has been written by different authors or/and has not been updated for quite some time. Still, both are intended to mean the same thing.
The page has now been updated to make the documentation language more consistent. In particular, now front says:
Calling front on an empty container causes undefined behavior.
Upvotes: 1