yat  0.20.3pre
Public Member Functions | List of all members
theplu::yat::utility::OstreamIterator< T > Class Template Reference

#include <yat/utility/OstreamIterator.h>

Inheritance diagram for theplu::yat::utility::OstreamIterator< T >:

Public Member Functions

 OstreamIterator (void)
 Default constructor. More...
 
 OstreamIterator (std::ostream &os, const std::string &delimiter="")
 Constructor. More...
 

Detailed Description

template<typename T>
class theplu::yat::utility::OstreamIterator< T >

OstreamIterator is an Output Iterator. Just like std::ostream_iterator it uses operator<<(ostream&, T) to send formatted output to a particular ostream. While std::ostream_iterator inserts a string delimited after each element, OstreamIterator only inserts delimiter between elements.

vector<int> x(3);
x[0] = 2;
x[1] = 3;
x[2] = 5;
copy(x.begin(), x.end(), OstreamIterator<int>(cout, ", "));

which will give output: 2, 3, 5

Since
New in yat 0.12

Constructor & Destructor Documentation

◆ OstreamIterator() [1/2]

template<typename T >
theplu::yat::utility::OstreamIterator< T >::OstreamIterator ( void  )
inline

Default constructor.

Creates an iterator that is not dereferencable.

◆ OstreamIterator() [2/2]

template<typename T >
theplu::yat::utility::OstreamIterator< T >::OstreamIterator ( std::ostream &  os,
const std::string &  delimiter = "" 
)
inlineexplicit

Constructor.

Creates an OstreamIterator such that assignment of t through it is equivalent to os << delimiter << t just like std::ostream_iterator. The exception is that first time OstreamIterator is derefenced the delimiter is excluded in order to get the desired behaviour that delimiter only occurs between elements.

Parameters
osostream to send output
delimiterthe delimiting string

The documentation for this class was generated from the following file:

Generated on Sat Feb 18 2023 03:31:45 for yat by  doxygen 1.8.14