protected virtual member function

std::streambuf::seekpos

<streambuf>
streampos seekpos ( streampos sp, ios_base::openmode which = ios_base::in | ios_base::out );
Set internal position pointer to absolute position
This member is called to set a new value for the position pointer in streambuf-derived objects. The public member function pubseekpos calls this protected member function to perform this action.

This is a virtual member function that shall be redefined in derived classes to behave as expected by setting the internal pointer specified by which to the absolute position sp.

Its default behavior in streambuf is to do nothing and return the invalid position -1, but it is redefined in both standard derived classes, filebuf and stringbuf, to behave as expected specifically for each type of buffer (see filebuf::seekpos and stringbuf::seekpos).

Parameters

sp
New absolute position for the position pointer.
This is an object of class streampos (or traits::pos_type for other traits). streampos objects may be constructed from streamoff directly from integral values representing a relative position from the beginning of the stream.
which
Determines which of the internal position pointers shall be modified: the input pointer, the output pointer, or both. It is an object of type ios_base::openmode that for this function may take any combination of the following significant constant values:
valueposition pointer affected
ios_base::ininput position pointer
ios_base::outoutput position pointer

Return Value

The new position value of the modified position pointer.
In case of error, the value returned shall be an invalid position, like -1.

Basic template member declaration

( basic_streambuf<charT,traits> )
1
2
typedef traits::pos_type pos_type;
pos_type seekpos (pos_type sp, ios_base which = ios_base::in | ios_base::out );


See also