std::basic_ostream<CharT,Traits>::seekp (3) - Linux Manuals
std::basic_ostream<CharT,Traits>::seekp: std::basic_ostream<CharT,Traits>::seekp
Command to display std::basic_ostream<CharT,Traits>::seekp
manual in Linux: $ man 3 std::basic_ostream<CharT,Traits>::seekp
NAME
std::basic_ostream<CharT,Traits>::seekp - std::basic_ostream<CharT,Traits>::seekp
Synopsis
basic_ostream& seekp( pos_type pos ); (1)
basic_ostream& seekp( off_type off, std::ios_base::seekdir dir ); (2)
Sets the output position indicator of the current associated streambuf object.
Behaves as UnformattedOutputFunction (except without actually performing output). After constructing and checking the sentry object, (since C++11)
1) sets the output position indicator to absolute (relative to the beginning of the file) value pos by calling rdbuf()->pubseekpos(pos, std::ios_base::out). If the call returns (pos_type)-1, executes setstate(failbit).
2) sets the output position indicator to offset off relative to dir by calling rdbuf()->pubseekoff(off, dir, std::ios_base::out).
Does not report errors. (until C++14)
If the call returns (pos_type)-1, executes setstate(failbit). (since C++14)
Parameters
pos - absolute position to set the output position indicator to.
off - relative position to set the output position indicator to.
defines base position to apply the relative offset to. It can be one of the following constants:
Constant Explanation
dir - beg the beginning of a stream
end the ending of a stream
cur the current position of stream position indicator
Return value
*this
Exceptions
1) May throw std::ios_base::failure in case of failure, if exceptions() & failbit != 0.
2)
Does not throw unless rdbuf()->pubseekoff() throws (until C++14)
May throw std::ios_base::failure in case of failure, if exceptions() & failbit != 0. (since C++14)
Example
// Run this code
#include <sstream>
#include <iostream>
int main()
{
std::ostringstream os("hello, world");
os.seekp(7);
os << 'W';
os.seekp(0, std::ios_base::end);
os << '!';
os.seekp(0);
os << 'H';
std::cout << os.str() << '\n';
}
Output:
Hello, World!
See also
returns the output position indicator
tellp (public member function)
returns the input position indicator
tellg (public member function of std::basic_istream<CharT,Traits>)
sets the input position indicator
seekg (public member function of std::basic_istream<CharT,Traits>)
Pages related to std::basic_ostream<CharT,Traits>::seekp
- std::basic_ostream<CharT,Traits>::sentry (3) - std::basic_ostream<CharT,Traits>::sentry
- std::basic_ostream<CharT,Traits>::swap (3) - std::basic_ostream<CharT,Traits>::swap
- std::basic_ostream<CharT,Traits>::basic_ostream (3) - std::basic_ostream<CharT,Traits>::basic_ostream
- std::basic_ostream<CharT,Traits>::flush (3) - std::basic_ostream<CharT,Traits>::flush
- std::basic_ostream<CharT,Traits>::operator<< (3) - std::basic_ostream<CharT,Traits>::operator<<
- std::basic_ostream<CharT,Traits>::operator= (3) - std::basic_ostream<CharT,Traits>::operator=
- std::basic_ostream<CharT,Traits>::put (3) - std::basic_ostream<CharT,Traits>::put
- std::basic_ostream<CharT,Traits>::tellp (3) - std::basic_ostream<CharT,Traits>::tellp
- std::basic_ostream<CharT,Traits>::write (3) - std::basic_ostream<CharT,Traits>::write
- std::basic_ostream<CharT,Traits>::~basic_ostream (3) - std::basic_ostream<CharT,Traits>::~basic_ostream
- std::basic_ostream (3) - std::basic_ostream
- std::basic_ostream_sentry (3)
- std::basic_ostringstream (3) - std::basic_ostringstream
- std::basic_ostringstream::operator= (3) - std::basic_ostringstream::operator=
- std::basic_ostringstream::rdbuf (3) - std::basic_ostringstream::rdbuf
- std::basic_ostringstream::swap (3) - std::basic_ostringstream::swap
- std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream (3) - std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream
- std::basic_ostringstream<CharT,Traits,Allocator>::str (3) - std::basic_ostringstream<CharT,Traits,Allocator>::str
- std::basic_osyncstream (3) - std::basic_osyncstream