<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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.15"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <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="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(initResizable); /* @license-end */</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 id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">libstdc++ </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.15 --> </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"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('a01500.html','');}); /* @license-end */ </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="a01477.html">Utilities</a> » <a class="el" href="a01496.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><div class="center"><iframe scrolling="no" frameborder="0" src="a01500.svg" width="244" height="35"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe> </div> </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="a07552.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="a07548.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:gaa48ba7f453a3e4aec335c304eab89d3b"><td class="memTemplParams" colspan="2">template<typename _Predicate > </td></tr> <tr class="memitem:gaa48ba7f453a3e4aec335c304eab89d3b"><td class="memTemplItemLeft" align="right" valign="top">_GLIBCXX14_CONSTEXPR <a class="el" href="a07548.html">unary_negate</a>< _Predicate > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a01500.html#gaa48ba7f453a3e4aec335c304eab89d3b">std::not1</a> (const _Predicate &__pred)</td></tr> <tr class="separator:gaa48ba7f453a3e4aec335c304eab89d3b"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga1244dfac05a74c4665bef243704f51b1"><td class="memTemplParams" colspan="2">template<typename _Predicate > </td></tr> <tr class="memitem:ga1244dfac05a74c4665bef243704f51b1"><td class="memTemplItemLeft" align="right" valign="top">_GLIBCXX14_CONSTEXPR <a class="el" href="a07552.html">binary_negate</a>< _Predicate > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a01500.html#ga1244dfac05a74c4665bef243704f51b1">std::not2</a> (const _Predicate &__pred)</td></tr> <tr class="separator:ga1244dfac05a74c4665bef243704f51b1"><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>unary_negate</code> or <code>binary_negate</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="a07308.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="a01481.html#gaaf6e9995ebbd27994d7c73b375f86088">std::find_if</a> (v.begin(), v.end(), <a class="code" href="a01500.html#gaa48ba7f453a3e4aec335c304eab89d3b">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 id="gaa48ba7f453a3e4aec335c304eab89d3b"></a> <h2 class="memtitle"><span class="permalink"><a href="#gaa48ba7f453a3e4aec335c304eab89d3b">◆ </a></span>not1()</h2> <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">_GLIBCXX14_CONSTEXPR <a class="el" href="a07548.html">unary_negate</a><_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="a01500.html">negation functors</a>. </p> <p class="definition">Definition at line <a class="el" href="a00542_source.html#l01000">1000</a> of file <a class="el" href="a00542_source.html">stl_function.h</a>.</p> </div> </div> <a id="ga1244dfac05a74c4665bef243704f51b1"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga1244dfac05a74c4665bef243704f51b1">◆ </a></span>not2()</h2> <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">_GLIBCXX14_CONSTEXPR <a class="el" href="a07552.html">binary_negate</a><_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="a01500.html">negation functors</a>. </p> <p class="definition">Definition at line <a class="el" href="a00542_source.html#l01028">1028</a> of file <a class="el" href="a00542_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.15 </li> </ul> </div> </body> </html>