The quote means that you cannot modify the return of operator[]( size() )
, even if the value is well defined. That is, you must not modify the NUL terminator in the string even through the non-const overload.
This is basically your first option: i.e. pos >= size()
, but because of the requirement pos <= size()
the only possible value for that condition is pos == size()
.
The actual English description of the clause can be ambiguous (at least to me), but Appendix C, and in particular C.2.11 deals with changes in semantics in the string library, and there is no mention to this change --that would break user code. In C++03 the "referenced value shall not be modified" bit is not present and there is no ambiguity. The lack of mention in C.2.11 is not normative, but can be used as a hint that when they wrote the standard there was no intention on changing this particular behavior.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…