Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::back_inserter

 

std::back_inserter is a type of inserter.

 

A good use of std::back_inserter is when you std::copy to a container class.

 

 

 

 

 

Example: Append

 

#include <algorithm

//From http://www.richelbilderbeek.nl
template <class Container>
void Append(Container& toWhat, const Container& whatToAppend)
{
  std::copy(whatToAppend.begin(),whatToAppend.end(),std::back_inserter (toWhat));
}

 

 

 

 

 

External links

 

  1. SGI's page about std::back_inserter

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict