4023. Preconditions of std::basic_streambuf::setg/setp

Section: [streambuf.protected] Status: New Submitter: Jiang An Opened: 2023-12-08 Last modified: 2023-12-09 16:21:45 UTC

Priority: Not Prioritized

View all issues with New status.


It seems that operations of std::basic_streambuf expect that

However, it is currently not specified for setg/setp that such invariants need to be established.

Proposed resolution:

This wording is relative to N4964.

  1. Modify [streambuf.get.area] as indicated:

    void setg(char_type* gbeg, char_type* gnext, char_type* gend);

    -?- Preconditions: [gbeg, gnext), [gbeg, gend), and [gnext, gend) are all valid ranges.

    -5- Postconditions: gbeg == eback(), gnext == gptr(), and gend == egptr() are all true.

  2. Modify [streambuf.put.area] as indicated:

    void setp(char_type* pbeg, char_type* pend);

    -?- Preconditions: [pbeg, pend) is a valid range.

    -5- Postconditions: pbeg == pbase(), pbeg == pptr(), and pend == epptr() are all true.