std::basic_filebuf<CharT,Traits>::seekpos (3) - Linux Man Pages
virtual pos_type seekpos( pos_type sp,
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out );
Repositions the file pointer, if possible, to the position indicated by sp.
If the associated file is not open (is_open()==false), fails immediately.
If the file is open for writing, first writes the put area and any unshift sequences required by the currently imbued locale, using overflow()
Then repositions the file pointer, as if by calling std::fsetpos()
If the file is open for reading, updates the get area if necessary.
If sp was not obtained by calling seekoff() or seekpos() on the same file, the behavior is undefined.
sp - file position obtained by seekoff() or seekpos() called earlier on the same file
which - Constant Explanation
sp on success or pos_type(off_type(-1)) on failure.
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()
Many implementations do not update the get area in seekpos(), delegating to underflow() that is called by the next sgetc()
on some implementations, the get area is emptied by seekpos() and the second underflow() is necessary to observe the effects
// Run this code
pubseekpos (public member function of std::basic_streambuf<CharT,Traits>)
seekoff repositions the file position, using relative addressing