(C++) std::ostream\_iterator

February 24, 2017 · View on GitHub

 

 

 

 

 

(C++) std::ostream_iterator

 

An iterator.

 

 

 

 

 

Example: CoutVector

 


#include <vector> #include <iterator> #include <iostream> #include <ostream> //From http://www.richelbilderbeek.nl/CppCoutVector.htm template <class T> void CoutVector(const std::vector<T>& v) {   std::copy(v.begin(),v.end(),std::ostream_iterator<T>(std::cout,"\n")); }

 

 

 

 

 

 

Contents

  1. 1Example: CoutVector
  2. 2#include #include #include //From http://www.richelbilderbeek.nl/CppCoutVector.htm template void CoutVector(const std::vector&#x26; v) { std::copy(v.begin(),v.end(),std::ostream_iterator(std::cout,&#x22;\n&#x22;)); }"> #include &#x3C;vector> #include &#x3C;iterator> #include &#x3C;iostream> #include &#x3C;ostream> //From http://www.richelbilderbeek.nl/CppCoutVector.htm template &#x3C;class T> void CoutVector(const std::vector&#x3C;T>&#x26; v) { std::copy(v.begin(),v.end(),std::ostream_iterator&#x3C;T>(std::cout,"\n")); }