std::strstreambuf::seekpos (3) - Linux Manuals
std::strstreambuf::seekpos: std::strstreambuf::seekpos
NAME
std::strstreambuf::seekpos - std::strstreambuf::seekpos
Synopsis
protected:
virtual pos_type seekpos(pos_type sp,
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out );
Repositions std::basic_streambuf::gptr and/or std::basic_streambuf::pptr, if possible, to the position indicated by sp
If std::ios_base::in is set in which, attempts to reposition gptr() (the next pointer in the get area). If std::ios_base::out is set in which, attempts to reposition pptr() (the next pointer in the put area). If neither bit is set in which, the operation fails.
Each next pointer is repositioned as follows:
1) If the next pointer is null, the operation fails
2) Otherwise, the new offset newoff (of type off_type) is determined by calling sp.offset(). If newoff is negative, out of bounds of the buffer, or invalid, the operation fails.
3) Otherwise, the next pointer is assigned as if by gptr() = eback()+newoff or pptr() = pbase()+newoff.
Parameters
sp - stream position, such as one obtained by seekoff() or seekpos()
which - Constant Explanation
Return value
The resultant offset converted to pos_type on success or pos_type(off_type(-1)) on failure.
Notes
seekpos() is called by std::basic_streambuf::pubseekpos(), which is called by the single-argument versions of std::basic_istream::seekg() and std::basic_ostream::seekp()
Example
// Run this code
Output:
See also
pubseekpos (public member function of std::basic_streambuf<CharT,Traits>)
seekpos repositions the next pointer in the input sequence, output sequence, or both using absolute addressing
[virtual]
seekpos repositions the file position, using absolute addressing
[virtual]
seekoff repositions the next pointer in the input sequence, output sequence, or both, using relative addressing