Udostępnij za pośrednictwem


basic_streambuf::seekpos

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

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

Parameters

  • _Sp
    The position to seek for.

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

Return Value

The new position, or an invalid stream position. To determine if the stream position is invalid, compare the return value with pos_type(off_type(-1)).

Remarks

The new position is _Sp.

Typically, if which & ios_base::in is nonzero, the input stream is affected, and if which & ios_base::out is nonzero, the output stream is affected. Actual use of this parameter varies among derived stream buffers, however.

If the function succeeds in altering the stream position or positions, it returns the resulting stream position or one of the resulting stream positions. Otherwise, it returns an invalid stream position (-1). The default behavior is to return an invalid stream position.

Requirements

Header: <streambuf>

Namespace: std

See Also

Reference

basic_streambuf Class

iostream Programming

iostreams Conventions

Other Resources

basic_streambuf Members