Class Template back_insert_device

Description
Headers
Synopsis

Description

The header <boost/iostreams/device/back_inserter.hpp> contains the definition of the class template back_insert_device — implementing a Sink which appends to a standard library sequence container — as well as the definition of a corresponding object generator, the function template boost::iostreams::back_inserter.

The Iostream Library allows OutputIterators to be used in many places where Sinks are allowed. However, using boost::iostreams::back_inserter my be somewhat more efficient than using std::back_inserter, since the former uses the function insert to append a sequence of characters in one operation. Furthermore, std::back_insert_iterator is not strictly a model of Sink, so one can write

namespace io = boost::iostreams;

typedef io::stream< io::back_insert_device<std::string> > my_stream

But not

typedef io::stream< std::back_insert_iterator<std::string> > my_stream

Headers

<boost/iostreams/device/back_inserter.hpp>

Synopsis

namespace boost { namespace iostreams {

template<typename Container>
class back_insert_device {
public:
    typedef typename Container::value_type  char_type;
    typedef sink_tag                        category;
    back_insert_device(Container& cnt);
    ... 
};

template<typename Container>
back_insert_device<Container> back_inserter(Container& cnt);

} } // End namespace boost::io

Template Parameters

Container- A C++ standard library sequence type ([ISO], 23.1.1).

back_insert_device::back_insert_device

    back_insert_device(Container& cnt);

Constructs an instance of back_insert_device for appending to the given container. The given reference must remain valid for the lifetime of the instance of back_insert_device.

back_inserter

template<typename Container>
back_insert_device<Container> back_inserter(Container& cnt);

Returns an instance of back_insert_device for appending to the given container.