<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.3"/> <title>libstdc++: Negators</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> $(document).ready(initResizable); $(window).load(resizeHeight); </script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">libstdc++ </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.3 --> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> $(document).ready(function(){initNavTree('a01661.html','');}); </script> <div id="doc-content"> <div class="header"> <div class="summary"> <a href="#nested-classes">Classes</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">Negators<div class="ingroups"><a class="el" href="a01657.html">Function Objects</a></div></div> </div> </div><!--header--> <div class="contents"> <div class="dynheader"> Collaboration diagram for Negators:</div> <div class="dyncontent"> <center><table><tr><td><img src="a01661.png" border="0" alt="" usemap="#a01661"/> <map name="a01661" id="a01661"> <area shape="rect" id="node2" href="a01657.html" title="Function Objects" alt="" coords="6,5,119,30"/></map> </td></tr></table></center> </div> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a> Classes</h2></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="a00596.html">std::binary_negate< _Predicate ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="a00940.html">std::unary_negate< _Predicate ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:ga1fa77600b0e213eaec448448f702ef40"><td class="memTemplParams" colspan="2">template<typename _Predicate > </td></tr> <tr class="memitem:ga1fa77600b0e213eaec448448f702ef40"><td class="memTemplItemLeft" align="right" valign="top">unary_negate< _Predicate > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a01661.html#ga1fa77600b0e213eaec448448f702ef40">std::not1</a> (const _Predicate &__pred)</td></tr> <tr class="separator:ga1fa77600b0e213eaec448448f702ef40"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga5ab22ed0b61c05cdae0da63eeb6e7d33"><td class="memTemplParams" colspan="2">template<typename _Predicate > </td></tr> <tr class="memitem:ga5ab22ed0b61c05cdae0da63eeb6e7d33"><td class="memTemplItemLeft" align="right" valign="top">binary_negate< _Predicate > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a01661.html#ga5ab22ed0b61c05cdae0da63eeb6e7d33">std::not2</a> (const _Predicate &__pred)</td></tr> <tr class="separator:ga5ab22ed0b61c05cdae0da63eeb6e7d33"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <p>The functions <code>not1</code> and <code>not2</code> each take a predicate functor and return an instance of <code><a class="el" href="a00940.html" title="One of the negation functors.">unary_negate</a></code> or <code><a class="el" href="a00596.html" title="One of the negation functors.">binary_negate</a></code>, respectively. These classes are functors whose <code>operator()</code> performs the stored predicate function and then returns the negation of the result.</p> <p>For example, given a vector of integers and a trivial predicate, </p> <div class="fragment"><div class="line"><span class="keyword">struct </span>IntGreaterThanThree</div> <div class="line"> : <span class="keyword">public</span> <a class="code" href="a00939.html">std::unary_function</a><int, bool></div> <div class="line">{</div> <div class="line"> <span class="keywordtype">bool</span> operator() (<span class="keywordtype">int</span> x) { <span class="keywordflow">return</span> x > 3; }</div> <div class="line">};</div> <div class="line"></div> <div class="line"><a class="code" href="a01647.html#gaaf6e9995ebbd27994d7c73b375f86088" title="Find the first element in a sequence for which a predicate is true.">std::find_if</a> (v.begin(), v.end(), <a class="code" href="a01661.html#ga1fa77600b0e213eaec448448f702ef40" title="One of the negation functors.">not1</a>(IntGreaterThanThree()));</div> </div><!-- fragment --><p> The call to <code>find_if</code> will locate the first index (i) of <code>v</code> for which <code>!(v[i] > 3)</code> is true.</p> <p>The not1/unary_negate combination works on predicates taking a single argument. The not2/binary_negate combination works on predicates which take two arguments. </p> <h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="ga1fa77600b0e213eaec448448f702ef40"></a> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _Predicate > </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">unary_negate<_Predicate> std::not1 </td> <td>(</td> <td class="paramtype">const _Predicate & </td> <td class="paramname"><em>__pred</em></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>One of the <a class="el" href="a01661.html">negation functors</a>. </p> <p>Definition at line <a class="el" href="a01495_source.html#l00371">371</a> of file <a class="el" href="a01495_source.html">stl_function.h</a>.</p> </div> </div> <a class="anchor" id="ga5ab22ed0b61c05cdae0da63eeb6e7d33"></a> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _Predicate > </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">binary_negate<_Predicate> std::not2 </td> <td>(</td> <td class="paramtype">const _Predicate & </td> <td class="paramname"><em>__pred</em></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>One of the <a class="el" href="a01661.html">negation functors</a>. </p> <p>Definition at line <a class="el" href="a01495_source.html#l00396">396</a> of file <a class="el" href="a01495_source.html">stl_function.h</a>.</p> </div> </div> </div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.3 </li> </ul> </div> </body> </html>