<experimental/iterator> synopsis#include <iterator>
namespace std::experimental::inline fundamentals_v3 {
template <class DelimT, class charT = char, class traits = char_traits<charT>>
class ostream_joiner;
template <class charT, class traits, class DelimT>
ostream_joiner<decay_t<DelimT>, charT, traits>
make_ostream_joiner(basic_ostream<charT, traits>& os, DelimT&& delimiter);
} // namespace std::experimental::inline fundamentals_v3
ostream_joiner
ostream_joiner writes (using operator<<) successive elements onto the output stream from which it was constructed.
The delimiter that it was constructed with is written to the stream between every two Ts that are written.
It is not possible to get a value out of the output iterator.
Its only use is as an output iterator in situations like
while (first != last)
*result++ = *first++;
ostream_joiner is defined as
namespace std::experimental::inline fundamentals_v3 {
template <class DelimT, class charT = char, class traits = char_traits<charT>>
class ostream_joiner {
public:
using char_type = charT;
using traits_type = traits;
using ostream_type = basic_ostream<charT, traits>;
using iterator_category = output_iterator_tag;
using value_type = void;
using difference_type = void;
using pointer = void;
using reference = void;
ostream_joiner(ostream_type& s, const DelimT& delimiter);
ostream_joiner(ostream_type& s, DelimT&& delimiter);
template<typename T>
ostream_joiner& operator=(const T& value);
ostream_joiner& operator*() noexcept;
ostream_joiner& operator++() noexcept;
ostream_joiner& operator++(int) noexcept;
private:
ostream_type* out_stream; // exposition only
DelimT delim; // exposition only
bool first_element; // exposition only
};
} // namespace std::experimental::inline fundamentals_v3
out_stream with std::addressof(s),
delim with delimiter,
and first_element with true.
out_stream with std::addressof(s),
delim with move(delimiter),
and first_element with true.
if (!first_element)
*out_stream << delim;
first_element = false;
*out_stream << value;
return *this;
*this.*this.ostream_joiner<decay_t<DelimT>, charT, traits>(os, forward<DelimT>(delimiter));