Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) std::stringstream

 

std::stringstream is a stream for std::strings.

 

The example below shows how to use std::stringstream to concatenate container elements.

 

#include <sstream>

template <class Container>
const std::string ContainerToStr(const Container& c, const std::string& seperator = " ")
{
  std::stringstream s;
  std::copy(c.begin(),c.end(),
    std::ostream_iterator<typename Container::value_type>(s,seperator.c_str()));
  return s.str();
}

 

 

 

 

 

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

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict