Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::basic_...::push_back(3)  C++ Standard Libary std::basic_...::push_back(3)

NAME
       std::basic_string::push_back - std::basic_string::push_back

Synopsis
	  void push_back( CharT	ch );		 (until	C++20)
	  constexpr void push_back( CharT ch );	 (since	C++20)

	  Appends the given character ch to the	end of the string.

Parameters
	  ch - the character to	append

Return value
	  (none)

Complexity
	  Amortized constant.

Exceptions
	  If  an  exception is thrown for any reason, this function has	no ef-
       fect (strong
	  exception guarantee).
	  (since C++11)

	  If the  operation  would  result  in	size()	>  max_size(),	throws
       std::length_error.

Example
       // Run this code

	#include <cassert>
	#include <string>
	#include <iomanip>
	#include <iostream>

	int main()
	{
	    std::string	str{"Short string"};
	    std::cout << "before=" << std::quoted(str) << '\n';
	    assert(str.size() == 12);

	    str.push_back('!');
	    std::cout << " after=" << quoted(str) << '\n';
	    assert(str.size() == 13);
	}

Output:
	before="Short string"
	 after="Short string!"

See also
	  pop_back removes the last character
	  (C++11)  (public member function)

http://cppreference.com		  2022.07.31	  std::basic_...::push_back(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::u32string::push_back&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help