ios::iword(-1) do?Section: 31.5.2.6 [ios.base.storage] Status: C++20 Submitter: Jonathan Wakely Opened: 2018-03-16 Last modified: 2021-02-25
Priority: 0
View all other issues in [ios.base.storage].
View all issues with C++20 status.
Discussion:
Is calling iword and pword with a negative argument undefined, or should it cause
a failure condition (and return a valid reference)? What about INT_MAX? What about 0?
ios_base::xalloc(). Others pointed out that the iwords and pwords could be stored in sparse
arrays, so that any value from INT_MIN to INT_MAX could be a valid key (which might
require the implementation to use keys outside that range for its own entries in the arrays).
If it's undefined we should add a Requires element to the spec. If invalid indices are supposed
to cause a failure we need to define which indices are invalid (and ensure that's something the
implementation can check), and specify that it causes a failure.
[ 2018-03-27 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
[2018-06 Rapperswil: Adopted]
Proposed resolution:
This wording is relative to N4727.
Edit 31.5.2.6 [ios.base.storage] as indicated:
long& iword(int idx);-?- Requires:
-3- Effects: Ifidxis a value obtained by a call toxalloc.iarrayis a null pointer, […] […]void*& pword(int idx);-?- Requires:
-5- Effects: Ifidxis a value obtained by a call toxalloc.iarrayis a null pointer, […] […]