]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <HTML> | |
3 | <HEAD> | |
4 | <TITLE>class template back_insert_device</TITLE> | |
5 | <LINK REL="stylesheet" HREF="../../../../boost.css"> | |
6 | <LINK REL="stylesheet" HREF="../theme/iostreams.css"> | |
7 | </HEAD> | |
8 | <BODY> | |
9 | ||
10 | <!-- Begin Banner --> | |
11 | ||
12 | <H1 CLASS="title">Class Template <CODE>back_insert_device</CODE></H1> | |
13 | <HR CLASS="banner"> | |
14 | ||
15 | <!-- End Banner --> | |
16 | ||
17 | <DL class="page-index"> | |
18 | <DT><A href="#description">Description</A></DT> | |
19 | <DT><A href="#headers">Headers</A></DT> | |
20 | <DT><A href="#synopsis">Synopsis</A></DT> | |
21 | </DL> | |
22 | ||
23 | <A NAME="description"></A> | |
24 | <H2>Description</H2> | |
25 | ||
26 | <P> | |
27 | The header <A CLASS="header" HREF="../../../../boost/iostreams/device/back_inserter.hpp"><CODE><boost/iostreams/device/back_inserter.hpp></CODE></A> contains the definition of the class template <CODE>back_insert_device</CODE> — implementing a <A HREF="../concepts/sink.html">Sink</A> which appends to a standard library sequence container — as well as the definition of a corresponding object generator, the function template <CODE>boost::iostreams::back_inserter</CODE>. | |
28 | </P> | |
29 | ||
30 | <P> | |
31 | The Iostream Library allows OutputIterators to be used in many places where <A HREF="../concepts/sink.html">Sinks</A> are allowed. However, using <CODE>boost::iostreams::back_inserter</CODE> my be somewhat more efficient than using <CODE>std::back_inserter</CODE>, since the former uses the function <CODE>insert</CODE> to append a sequence of characters in one operation. Furthermore, <CODE>std::back_insert_iterator</CODE> is not strictly a model of <A HREF="../concepts/sink.html">Sink</A>, so one can write | |
32 | </P> | |
33 | ||
34 | <PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> io = boost::iostreams; | |
35 | ||
36 | <SPAN CLASS="keyword">typedef</SPAN> io::stream< io::back_insert_device<std::string> > my_stream</PRE> | |
37 | ||
38 | <P>But not</P> | |
39 | ||
40 | <PRE CLASS="broken_ie"><SPAN CLASS="keyword">typedef</SPAN> io::stream< std::back_insert_iterator<std::string> > my_stream</PRE> | |
41 | ||
42 | <A NAME="headers"></A> | |
43 | <H2>Headers</H2> | |
44 | ||
45 | <DL> | |
46 | <DT><A CLASS="header" HREF="../../../../boost/iostreams/device/back_inserter.hpp"><CODE><boost/iostreams/device/back_inserter.hpp></CODE></A></DT> | |
47 | </DL> | |
48 | ||
49 | <A NAME="synopsis"></A> | |
50 | <H2>Synopsis</H2> | |
51 | ||
52 | <PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams { | |
53 | ||
54 | <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> <A HREF="#back_insert_device_template_params" CLASS="documented">Container</A>> | |
55 | <SPAN CLASS="keyword">class</SPAN> <A HREF="#back_insert_device_template_params" CLASS="documented">back_insert_device</A> { | |
56 | <SPAN CLASS="keyword">public</SPAN>: | |
57 | <SPAN CLASS="keyword">typedef</SPAN> <SPAN CLASS="keyword">typename</SPAN> Container::value_type char_type; | |
58 | <SPAN CLASS="keyword">typedef</SPAN> sink_tag category; | |
59 | <A HREF="#back_insert_device_constructor" CLASS="documented">back_insert_device</A>(Container& cnt); | |
60 | <SPAN CLASS="omitted">...</SPAN> | |
61 | }; | |
62 | ||
63 | <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> <A HREF="#back_insert_device_template_params" CLASS="documented">Container</A>> | |
64 | <A CLASS="documented" HREF="#back_insert_device_template_params">back_insert_device</A><Container> <A CLASS="documented" HREF="#back_inserter">back_inserter</A>(Container& cnt); | |
65 | ||
66 | } } <SPAN CLASS="comment">// End namespace boost::io</SPAN></PRE> | |
67 | ||
68 | <A NAME="back_insert_device_template_params"></A> | |
69 | <H4>Template Parameters</H4> | |
70 | ||
71 | <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> | |
72 | <TR> | |
73 | <TR> | |
74 | <TD VALIGN="top"><I>Container</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> | |
75 | <TD>A C++ standard library sequence type (<A CLASS="bib_ref" HREF="../bibliography.html#iso">[ISO]</A>, 23.1.1). | |
76 | </TR> | |
77 | </TABLE> | |
78 | ||
79 | <A NAME="back_insert_device_constructor"></A> | |
80 | <H4><CODE>back_insert_device::back_insert_device</CODE></H4> | |
81 | ||
82 | <PRE CLASS="broken_ie"> back_insert_device(Container& cnt);</PRE> | |
83 | ||
84 | <P>Constructs an instance of <CODE>back_insert_device</CODE> for appending to the given container. The given reference must remain valid for the lifetime of the instance of <CODE>back_insert_device</CODE>.</P> | |
85 | ||
86 | <A NAME="back_inserter"></A> | |
87 | <H4><CODE>back_inserter</CODE></H4> | |
88 | ||
89 | <PRE CLASS="broken_ie"><SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Container> | |
90 | back_insert_device<Container> back_inserter(Container& cnt);</PRE> | |
91 | ||
92 | <P>Returns an instance of <CODE>back_insert_device</CODE> for appending to the given container.</P> | |
93 | ||
94 | <!-- Begin Footer --> | |
95 | ||
96 | <HR> | |
97 | ||
98 | <P CLASS="copyright">© Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>© Copyright 2004-2007 <a href="http://www.coderage.com/turkanis/" target="_top">Jonathan Turkanis</a></P> | |
99 | <P CLASS="copyright"> | |
100 | Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>) | |
101 | </P> | |
102 | ||
103 | <!-- End Footer --> | |
104 | ||
105 | </BODY> |