Dela via


basic_stringbuf::seekpos

The protected virtual member function tries to alter the current positions for the controlled streams.

virtual pos_type seekpos(
   pos_type _Sp,
   ios_base::openmode _Mode = ios_base::in | ios_base::out
);

Parameters

  • _Sp
    The position to seek for.

  • _Mode
    Specifies the mode for the pointer position. The default is to allow you to modify the read and write positions.

Return Value

If the function succeeds in altering either or both of the stream positions, it returns the resultant stream position. Otherwise, it fails and returns an invalid stream position. To determine if the stream position is invalid, compare the return value with pos_type(off_type(-1)).

Remarks

For an object of class basic_stringbuf<Elem, Tr, Alloc>, a stream position consists purely of a stream offset. Offset zero designates the first element of the controlled sequence. The new position is determined by _Sp.

If mode & ios_base::in is nonzero, the function alters the next position to read in the input buffer. If mode & ios_base::out is nonzero, the function alters the next position to write in the output buffer. For a stream to be affected, its buffer must exist. For a positioning operation to succeed, the resulting stream position must lie within the controlled sequence. Otherwise (or if neither position is affected), the positioning operation fails.

Requirements

Header: <sstream>

Namespace: std

See Also

Reference

basic_stringbuf Class

iostream Programming

iostreams Conventions

Other Resources

basic_stringbuf Members