Files
cppdraft_translate/cppdraft/streambuf/reqts.md
2025-10-25 03:02:53 +03:00

3.7 KiB
Raw Blame History

[streambuf.reqts]

31 Input/output library [input.output]

31.6 Stream buffers [stream.buffers]

31.6.2 Stream buffer requirements [streambuf.reqts]

1

#

Stream buffers can impose various constraints on the sequences they control.

Some constraints are:

  • (1.1)

    The controlled input sequence can be not readable.

  • (1.2)

    The controlled output sequence can be not writable.

  • (1.3)

    The controlled sequences can be associated with the contents of other representations for character sequences, such as external files.

  • (1.4)

    The controlled sequences can support operationsdirectly to or from associated sequences.

  • (1.5)

    The controlled sequences can impose limitations on how the program can read characters from a sequence, write characters to a sequence, put characters back into an input sequence, or alter the stream position.

2

#

Each sequence is characterized by three pointers which, if non-null, all point into the samecharT array object.

The array object represents, at any moment, a (sub)sequence of characters from the sequence.

Operations performed on a sequence alter the values stored in these pointers, perform reads and writes directly to or from associated sequences, and alter “the stream position” and conversion state as needed to maintain this subsequence relationship.

The three pointers are:

thebeginning pointer, or lowest element address in the array (called xbeg here);

thenext pointer, or next element address that is a current candidate for reading or writing (called xnext here);

theend pointer, or first element address beyond the end of the array (called xend here).

3

#

The following semantic constraints shall always apply for any set of three pointers for a sequence, using the pointer names given immediately above:

  • (3.1)

    If xnext is not a null pointer, thenxbeg and xend shall also be non-null pointers into the samecharT array, as described above; otherwise, xbeg andxend shall also be null.

  • (3.2)

    If xnext is not a null pointer andxnext < xend for an output sequence, then awrite position is available. In this case,*xnext shall be assignable as the next element to write (to put, or to store a character value, into the sequence).

  • (3.3)

    If xnext is not a null pointer andxbeg < xnext for an input sequence, then aputback position is available. In this case,xnext[-1] shall have a defined value and is the next (preceding) element to store a character that is put back into the input sequence.

  • (3.4)

    If xnext is not a null pointer andxnext < xend for an input sequence, then aread position is available. In this case,*xnext shall have a defined value and is the next element to read (to get, or to obtain a character value, from the sequence).