1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4 <TITLE>Function Template restrict</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">Function Template <CODE>restrict</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="#reference">Reference</A></DT> 21</DL> 22 23<HR> 24 25<A NAME="description"></A> 26<H2>Description</H2> 27 28<P> 29 Given a Filter or Device that provides access to a single character sequence, we can construct a second Filter or Device which provides access to contiguous subsequence of the the original sequence. This second Filter or Device is called a <I>restriction</I> of the original device. Restrictions are represented by instances of the class template <CODE>restriction</CODE>. The function template <CODE>resrict</CODE> is an <A HREF='http://www.boost.org/more/generic_programming.html#object_generator' TARGET='_top'>object generator</A> which returns an appropriate instance of <CODE>resriction</CODE> when passed a Filter or Device and a pair of values indicating the endpoints of the restricted subsequence. 30</P> 31 32<P> 33 The <A HREF='../guide/modes.html'>mode</A> of a <CODE>resriction</CODE> is the same as that of the underlying component. A <CODE>resriction</CODE> is <A HREF='../concepts/closable.html'>Closable</A>, <A HREF='../concepts/flushable.html'>Flushable</A>, <A HREF='../concepts/localizable.html'>Localizable</A> and <A HREF='../concepts/optimally_buffered.html'>OptimallyBuffered</A>. 34</P> 35 36<P> 37 The function template <a href="slice.html"><code>slice</code></a> is available as an alias of <code>restrict</code>, for platforms that treat <code>restrict</code> as a keyword. 38</P> 39 40<A NAME="headers"></A> 41<H2>Headers</H2> 42 43<DL class="page-index"> 44 <DT><A CLASS="header" HREF="../../../../boost/iostreams/restrict.hpp"><CODE><boost/iostreams/restrict.hpp></CODE></A></DT> 45</DL> 46 47<A NAME="reference"></A> 48<H2>Reference</H2> 49 50<A NAME="synopsis"></A> 51<H4>Synopsis</H4> 52 53<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams { 54 55<SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#restriction_template_params">Component</A>> 56<SPAN CLASS='keyword'>class</SPAN> <A CLASS='documented' HREF='#restriction'>restriction</A> { 57<SPAN CLASS='keyword'>public:</SPAN> 58 <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='keyword'>typename</SPAN> <A CLASS='documented' HREF='../guide/traits.html#char_type_of_ref'>char_type_of</A><Component>::type char_type; 59 <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>implementation-defined</SPAN> mode; 60 61 <A CLASS='documented' HREF='#restriction_ctor'>restriction</A>( [<SPAN CLASS='keyword'>const</SPAN>] Component& component, 62 <A CLASS='documented' HREF='positioning.html#synopsis'>stream_offset</A> off, 63 <A CLASS='documented' HREF='positioning.html#synopsis'>stream_offset</A> len = <SPAN CLASS='literal'>-1</SPAN> ); 64 65 <SPAN CLASS='comment'>// Filter or Device member functions</SPAN> 66}; 67 68<SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#restrict_template_params">Component</A>> 69<A CLASS='documented' HREF='#restriction'>restriction</A><Component> 70<A CLASS='documented' HREF='#restrict'>restrict</A>( [<SPAN CLASS='keyword'>const</SPAN>] Component& component, 71 <A CLASS='documented' HREF='positioning.html#synopsis'>stream_offset</A> off, 72 <A CLASS='documented' HREF='positioning.html#synopsis'>stream_offset</A> len = <SPAN CLASS='literal'>-1</SPAN> ); 73 74} } // End namespace boost::io</PRE> 75 76<A NAME="restriction"></A> 77<H2>Class Template <CODE>restriction</CODE></H2> 78 79<A NAME="restriction_template_params"></A> 80<H4>Template parameters</H4> 81 82<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> 83<TR> 84 <TR> 85 <TD VALIGN="top"><I>Component</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> 86 <TD>A model of <A HREF='../concepts/filter.html'>Filter</A> or <A HREF='../concepts/device.html'>Device</A></TD> 87 </TR> 88</TABLE> 89 90<A NAME="restriction_ctor"></A> 91<H4><CODE>restriction::restriction</CODE></H4> 92 93<PRE CLASS="broken_ie"> restriction( [<SPAN CLASS='keyword'>const</SPAN>] Component& component, 94 <A CLASS='documented' HREF='positioning.html#synopsis'>stream_offset</A> off, 95 <A CLASS='documented' HREF='positioning.html#synopsis'>stream_offset</A> len = <SPAN CLASS='literal'>-1</SPAN> );</PRE> 96 97<P> 98 Constructs an instance of <CODE>restriction</CODE> based on the given component and offsets. The parameters have the following interpretation: 99</P> 100 101<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> 102<TR> 103 <TR> 104 <TD VALIGN="top"><I>component</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> 105 <TD>The Filter or Device to be restricted. If <CODE>Component</CODE> is a stream or stream buffer type, the function parameter is a non-<CODE>const</CODE> reference; otherwise it is a <CODE>const</CODE> reference.</TD> 106 </TR> 107 <TR> 108 <TD VALIGN="top"><I>off</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> 109 <TD>The offset of the beginning of the restricted character sequence.</TD> 110 </TR> 111 <TR> 112 <TD VALIGN="top"><I>len</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> 113 <TD>The length of the restricted character sequence. A value of <CODE>-1</CODE> indicates that the end of the restricted sequence should be the same as that of the unrestricted sequence.</TD> 114 </TR> 115</TABLE> 116 117<A NAME="restrict"></A> 118<H2>Function Template <CODE>restrict</CODE></H2> 119 120<PRE CLASS="broken_ie"><SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Component> 121restriction<Component> 122restrict( [<SPAN CLASS='keyword'>const</SPAN>] Component& component, 123 <A CLASS='documented' HREF='positioning.html#synopsis'>stream_offset</A> off, 124 <A CLASS='documented' HREF='positioning.html#synopsis'>stream_offset</A> len = <SPAN CLASS='literal'>-1</SPAN> );</PRE> 125 126<A NAME="restrict_template_params"></A> 127<H4>Template parameters</H4> 128 129<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> 130<TR> 131 <TR> 132 <TD VALIGN="top"><I>Component</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> 133 <TD>A model of <A HREF='../concepts/filter.html'>Filter</A> or <A HREF='../concepts/device.html'>Device</A></TD> 134 </TR> 135</TABLE> 136 137<P> 138 Constructs an instance of an appropriate specialization of <CODE>restriction</CODE> based on the given component and offsets. The parameters have the following interpretation: 139</P> 140 141<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> 142<TR> 143 <TR> 144 <TD VALIGN="top"><I>component</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> 145 <TD>The Filter or Device to be restricted. If <CODE>Component</CODE> is a stream or stream buffer type, the function parameter is a non-<CODE>const</CODE> reference; otherwise it is a <CODE>const</CODE> reference.</TD> 146 </TR> 147 <TR> 148 <TD VALIGN="top"><I>off</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> 149 <TD>The offset of the beginning of the restricted character sequence.</TD> 150 </TR> 151 <TR> 152 <TD VALIGN="top"><I>len</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> 153 <TD>The length of the restricted character sequence. A value of <CODE>-1</CODE> indicates that the end of the restricted sequence should be the same as that of the unrestricted sequence.</TD> 154 </TR> 155</TABLE> 156 157<!-- Begin Footer --> 158 159<HR> 160 161<P CLASS="copyright">© Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>© Copyright 2004-2007 <a href="https://www.boost.org/users/people/jonathan_turkanis.html" target="_top">Jonathan Turkanis</a></P> 162<P CLASS="copyright"> 163 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>) 164</P> 165 166<!-- End Footer --> 167 168</BODY> 169