Unspecified does not mean undefined.
According to the C ++ 11 standard, section 17.3.26:
actual, but undefined state state of the object that is not specified, except that the invariants of the objects are satisfied, and operations on the object behave as indicated for its type
Since the object is in a valid state, you can pass it to the output because streaming does not have additional prerequisites. However, what is printed is not indicated, so it may simply not print or print that your father smells like elderberry. What you cannot safely do is use a function with additional preconditions such as back() , which additionally requires the line to be nonempty. Valid lines may be empty.
Containing the old value is a perfectly acceptable option for an unspecified but valid state. In the case of fundamental types such as int , a simple copy is just the most efficient way to perform the move.
It should also be noted that int not a standard library object, but a fundamental type (as defined in section 3.9.1). Therefore, your quote does not apply.
source share