1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>filter</title> 5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../../index.html" title="Chapter 1. Fusion 2.2"> 8<link rel="up" href="../functions.html" title="Functions"> 9<link rel="prev" href="../functions.html" title="Functions"> 10<link rel="next" href="filter_if.html" title="filter_if"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="../functions.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="filter_if.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h5 class="title"> 27<a name="fusion.algorithm.transformation.functions.filter"></a><a class="link" href="filter.html" title="filter">filter</a> 28</h5></div></div></div> 29<h6> 30<a name="fusion.algorithm.transformation.functions.filter.h0"></a> 31 <span class="phrase"><a name="fusion.algorithm.transformation.functions.filter.description"></a></span><a class="link" href="filter.html#fusion.algorithm.transformation.functions.filter.description">Description</a> 32 </h6> 33<p> 34 For a given sequence, filter returns a new sequences containing only 35 the elements of a specified type. 36 </p> 37<h6> 38<a name="fusion.algorithm.transformation.functions.filter.h1"></a> 39 <span class="phrase"><a name="fusion.algorithm.transformation.functions.filter.synopsis"></a></span><a class="link" href="filter.html#fusion.algorithm.transformation.functions.filter.synopsis">Synopsis</a> 40 </h6> 41<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> 42 <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> 43 <span class="keyword">typename</span> <span class="identifier">Sequence</span> 44 <span class="special">></span> 45<span class="keyword">typename</span> <a class="link" href="../metafunctions/filter.html" title="filter"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">filter</span></code></a><span class="special"><</span><span class="identifier">Sequence</span> <span class="keyword">const</span><span class="special">,</span> <span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">filter</span><span class="special">(</span><span class="identifier">Sequence</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">seq</span><span class="special">);</span> 46</pre> 47<div class="table"> 48<a name="fusion.algorithm.transformation.functions.filter.t0"></a><p class="title"><b>Table 1.66. Parameters</b></p> 49<div class="table-contents"><table class="table" summary="Parameters"> 50<colgroup> 51<col> 52<col> 53<col> 54</colgroup> 55<thead><tr> 56<th> 57 <p> 58 Parameter 59 </p> 60 </th> 61<th> 62 <p> 63 Requirement 64 </p> 65 </th> 66<th> 67 <p> 68 Description 69 </p> 70 </th> 71</tr></thead> 72<tbody> 73<tr> 74<td> 75 <p> 76 <code class="computeroutput"><span class="identifier">seq</span></code> 77 </p> 78 </td> 79<td> 80 <p> 81 A model of <a class="link" href="../../../sequence/concepts/forward_sequence.html" title="Forward Sequence">Forward 82 Sequence</a> 83 </p> 84 </td> 85<td> 86 <p> 87 Operation's argument 88 </p> 89 </td> 90</tr> 91<tr> 92<td> 93 <p> 94 <code class="computeroutput"><span class="identifier">T</span></code> 95 </p> 96 </td> 97<td> 98 <p> 99 Any type 100 </p> 101 </td> 102<td> 103 <p> 104 The type to retain 105 </p> 106 </td> 107</tr> 108</tbody> 109</table></div> 110</div> 111<br class="table-break"><h6> 112<a name="fusion.algorithm.transformation.functions.filter.h2"></a> 113 <span class="phrase"><a name="fusion.algorithm.transformation.functions.filter.expression_semantics"></a></span><a class="link" href="filter.html#fusion.algorithm.transformation.functions.filter.expression_semantics">Expression 114 Semantics</a> 115 </h6> 116<pre class="programlisting"><a class="link" href="filter.html" title="filter"><code class="computeroutput"><span class="identifier">filter</span></code></a><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">seq</span><span class="special">);</span> 117</pre> 118<p> 119 <span class="bold"><strong>Return type</strong></span>: 120 </p> 121<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 122<li class="listitem"> 123 A model of <a class="link" href="../../../sequence/concepts/forward_sequence.html" title="Forward Sequence">Forward 124 Sequence</a>. 125 </li> 126<li class="listitem"> 127 A model of <a class="link" href="../../../sequence/concepts/associative_sequence.html" title="Associative Sequence">Associative 128 Sequence</a> if <code class="computeroutput"><span class="identifier">seq</span></code> 129 implements the <a class="link" href="../../../sequence/concepts/associative_sequence.html" title="Associative Sequence">Associative 130 Sequence</a> model. 131 </li> 132</ul></div> 133<p> 134 <span class="bold"><strong>Semantics</strong></span>: Returns a sequence containing 135 all the elements of <code class="computeroutput"><span class="identifier">seq</span></code> 136 of type <code class="computeroutput"><span class="identifier">T</span></code>. Equivalent 137 to <code class="computeroutput"><a class="link" href="filter_if.html" title="filter_if"><code class="computeroutput"><span class="identifier">filter_if</span></code></a><span class="special"><</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">same_type</span><span class="special"><</span><span class="identifier">_</span><span class="special">,</span> <span class="identifier">T</span><span class="special">></span> <span class="special">>(</span><span class="identifier">seq</span><span class="special">)</span></code>. 138 </p> 139<h6> 140<a name="fusion.algorithm.transformation.functions.filter.h3"></a> 141 <span class="phrase"><a name="fusion.algorithm.transformation.functions.filter.complexity"></a></span><a class="link" href="filter.html#fusion.algorithm.transformation.functions.filter.complexity">Complexity</a> 142 </h6> 143<p> 144 Constant. Returns a view which is lazily evaluated. 145 </p> 146<h6> 147<a name="fusion.algorithm.transformation.functions.filter.h4"></a> 148 <span class="phrase"><a name="fusion.algorithm.transformation.functions.filter.header"></a></span><a class="link" href="filter.html#fusion.algorithm.transformation.functions.filter.header">Header</a> 149 </h6> 150<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">transformation</span><span class="special">/</span><span class="identifier">filter</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 151<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">filter</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 152</pre> 153<h6> 154<a name="fusion.algorithm.transformation.functions.filter.h5"></a> 155 <span class="phrase"><a name="fusion.algorithm.transformation.functions.filter.example"></a></span><a class="link" href="filter.html#fusion.algorithm.transformation.functions.filter.example">Example</a> 156 </h6> 157<pre class="programlisting"><span class="keyword">const</span> <a class="link" href="../../../container/vector.html" title="vector"><code class="computeroutput"><span class="identifier">vector</span></code></a><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="keyword">int</span><span class="special">,</span><span class="keyword">long</span><span class="special">,</span><span class="keyword">long</span><span class="special">></span> <span class="identifier">vec</span><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">4</span><span class="special">);</span> 158<span class="identifier">assert</span><span class="special">(</span><a class="link" href="filter.html" title="filter"><code class="computeroutput"><span class="identifier">filter</span></code></a><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span><span class="identifier">vec</span><span class="special">)</span> <span class="special">==</span> <a class="link" href="../../../container/generation/functions/make_vector.html" title="make_vector"><code class="computeroutput"><span class="identifier">make_vector</span></code></a><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">));</span> 159</pre> 160</div> 161<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 162<td align="left"></td> 163<td align="right"><div class="copyright-footer">Copyright © 2001-2006, 2011, 2012 Joel de Guzman, 164 Dan Marsden, Tobias Schwinger<p> 165 Distributed under the Boost Software License, Version 1.0. (See accompanying 166 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 167 </p> 168</div></td> 169</tr></table> 170<hr> 171<div class="spirit-nav"> 172<a accesskey="p" href="../functions.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="filter_if.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 173</div> 174</body> 175</html> 176