std::basic_stringbuf::seekpos

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. Effectively executes seekoff(off_type(sp), std::ios_base::beg, which). Parameters sp - stream position, such as one obtained by seekoff() or seekpos() which - defines whether the input sequences, the output se

std::basic_stringbuf::seekoff

protected: virtual pos_type seekoff(off_type off, ios_base::seekdir dir, ios_base::openmode which = ios_base::in | ios_base::out); Repositions std::basic_streambuf::gptr and/or std::basic_streambuf::pptr, if possible, to the position that corresponds to exactly off characters from beginning, end, or current position of the get and/or put area of the buffer. If which includes ios_base::in and this buffer is open for reading (that is, if

std::basic_stringbuf::pbackfail

protected: virtual int_type pbackfail( int_type c = Traits::eof() ) This protected virtual function is called by the public functions basic_streambuf::sungetc and basic_streambuf::sputbackc (which, in turn, are called by basic_istream::unget and basic_istream::putback). 1) The caller is requesting that the get area is backed up by one character (pbackfail() is called with no arguments or with Traits::eof() as the argument) a) First, checks if there is a putback position, and if there

std::basic_stringbuf::overflow

protected: virtual int_type overflow ( int_type c = Traits::eof() ); Appends the character c to the output character sequence. If c is the end-of-file indicator traits::eq_int_type(c,traits::eof()) == true, then there is no character to append. The function does nothing and returns an unspecified value other than traits::eof(). Otherwise, if the output sequence has a write position available or this function can successfully make a write position available, then calls sputc(c) and retur

std::basic_stringbuf::basic_stringbuf

explicit basic_stringbuf( std::ios_base::openmode which = std::ios_base::in | std::ios_base::out ); (1) explicit basic_stringbuf( const std::basic_string<CharT, traits, Allocator>& new_str, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out ); (2) basic_stringbuf( const basic_stringbuf& rhs ) = delete; (3) (s

std::basic_stringbuf

Defined in header <sstream> template< class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT> > class basic_stringbuf : public std::basic_streambuf<CharT, Traits> std::basic_stringbuf is a std::basic_streambuf whose associated character sequence is a memory-resident sequence of arbitrary characters, which can be initialized from or made available as an instance of std::basic_string. Typical impleme

std::basic_string::swap

void swap( basic_string& other ); Exchanges the contents of the string with those of other. All iterators and references may be invalidated. Parameters other - string to exchange the contents with Return value (none). Exceptions noexcept specification: noexcept(std::allocator_traits<Allocator>::propagate_on_container_swap::value|| std::allocator_traits<Allocator>::is_always_equal::value) (since C++17) Example #include <string> #include &

std::basic_string::substr

basic_string substr( size_type pos = 0, size_type count = npos ) const; Returns a substring [pos, pos+count). If the requested substring extends past the end of the string, or if count == npos, the returned substring is [pos, size()). Parameters pos - position of the first character to include count - length of the substring Return value An empty string if pos == size(). String containing the substring [pos, pos+count). Exceptions std::

std::basic_string::size

size_type size() const; size_type length() const; Returns the number of CharT elements in the string, i.e. std::distance(begin(), end()). Parameters (none). Return value The number of CharT elements in the string. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. Notes For std::string, the elements are bytes (objects of type char), which are not the same as characters if a multibyte encoding such as UTF-8 is

std::basic_string::shrink_to_fit

void shrink_to_fit(); (since C++11) Requests the removal of unused capacity. It is a non-binding request to reduce capacity to size. It depends on the implementation if the request is fulfilled. Parameters (none). Return value (none). Complexity Constant. Example #include <iostream> #include <string> int main() { std::string s; std::cout << "Default-constructed capacity is " << s.capacity() << '\n'; s.resize(100); std::cout &