2 Copyright 2019 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_IO_OSTREAM_JOINER_HPP
9 #define BOOST_IO_OSTREAM_JOINER_HPP
11 #include <boost/config.hpp>
14 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
15 #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
16 #include <type_traits>
25 #if !defined(BOOST_NO_CXX11_ADDRESSOF)
30 return std::addressof(o);
43 template<class Delim, class Char = char,
44 class Traits = std::char_traits<Char> >
45 class ostream_joiner {
47 typedef Char char_type;
48 typedef Traits traits_type;
49 typedef std::basic_ostream<Char, Traits> ostream_type;
50 typedef std::output_iterator_tag iterator_category;
51 typedef void value_type;
52 typedef void difference_type;
54 typedef void reference;
56 ostream_joiner(ostream_type& output, const Delim& delim)
57 : output_(detail::osj_address(output))
61 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
62 ostream_joiner(ostream_type& output, Delim&& delim)
63 : output_(detail::osj_address(output))
64 , delim_(std::move(delim))
69 ostream_joiner& operator=(const T& value) {
78 ostream_joiner& operator*() BOOST_NOEXCEPT {
82 ostream_joiner& operator++() BOOST_NOEXCEPT {
86 ostream_joiner& operator++(int) BOOST_NOEXCEPT {
91 ostream_type* output_;
96 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
97 !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
98 template<class Char, class Traits, class Delim>
99 inline ostream_joiner<typename std::decay<Delim>::type, Char, Traits>
100 make_ostream_joiner(std::basic_ostream<Char, Traits>& output, Delim&& delim)
102 return ostream_joiner<typename std::decay<Delim>::type, Char,
103 Traits>(output, std::forward<Delim>(delim));
106 template<class Char, class Traits, class Delim>
107 inline ostream_joiner<Delim, Char, Traits>
108 make_ostream_joiner(std::basic_ostream<Char, Traits>& output,
111 return ostream_joiner<Delim, Char, Traits>(output, delim);