4.9 KiB
[ios.base.storage]
31 Input/output library [input.output]
31.5 Iostreams base classes [iostreams.base]
31.5.2 Class ios_base [ios.base]
31.5.2.6 Storage functions [ios.base.storage]
static int xalloc();
Returns: index++.
Remarks: Concurrent access to this function by multiple threads does not result in adata race.
long& iword(int idx);
Preconditions: idx is a value obtained by a call to xalloc.
Effects: If iarray is a null pointer, allocates an array oflong of unspecified size and stores a pointer to its first element iniarray.
The function then extends the array pointed at byiarray as necessary to include the elementiarray[idx].
Each newly allocated element of the array is initialized to zero.
The reference returned is invalid after any other operation on the object.260
However, the value of the storage referred to is retained, so that until the next call tocopyfmt, callingiword with the same index yields another reference to the same value.
If the function fails261 and*this is a base class subobject of abasic_ios<> object or subobject, the effect is equivalent to callingbasic_ios<>::setstate(badbit) on the derived object (which may throwfailure).
Returns: On successiarray[idx].
On failure, a validlong& initialized to 0.
void*& pword(int idx);
Preconditions: idx is a value obtained by a call to xalloc.
Effects: If parray is a null pointer, allocates an array of pointers to void of unspecified size and stores a pointer to its first element in parray.
The function then extends the array pointed at by parray as necessary to include the elementparray[idx].
Each newly allocated element of the array is initialized to a null pointer.
The reference returned is invalid after any other operation on the object.
However, the value of the storage referred to is retained, so that until the next call tocopyfmt, callingpword with the same index yields another reference to the same value.
If the function fails262 and*this is a base class subobject of abasic_ios<> object or subobject, the effect is equivalent to callingbasic_ios<>::setstate(badbit) on the derived object (which may throwfailure).
Returns: On successparray[idx].
On failure a validvoid*& initialized to 0.
Remarks: After a subsequent call topword(int) for the same object, the earlier return value may no longer be valid.
An implementation is free to implement both the integer array pointed at by iarray and the pointer array pointed at byparray as sparse data structures, possibly with a one-element cache for each.
For example, because it cannot allocate space.
For example, because it cannot allocate space.