Section

std::experimental::ostream_joiner

std::experimental::ostream_joiner is a single-pass LegacyOutputIterator that writes successive objects into the std::basic_ostream object for which it was constructed, using operator«, separated by a delimiter. The delimiter is written to the output stream between every two objects that are written. The write operation is performed when the iterator (whether dereferenced or not) is assigned to. Incrementing the ostream_joiner is a no-op.

# Declarations

template<
class DelimT,
class CharT = char,
class Traits = std::char_traits<CharT>
>
class ostream_joiner;

(library fundamentals TS v2)

# Example

#include <algorithm>
#include <experimental/iterator>
#include <iostream>
#include <iterator>
 
int main()
{
    int i[] = {1, 2, 3, 4, 5};
    std::copy(std::begin(i),
              std::end(i),
              std::experimental::make_ostream_joiner(std::cout, ", "));
}

# See also