📄 log_1866.htm
字号:
<HTML><TITLE>logical_not</TITLE><BODY>
<A HREF="ref.htm"><IMG SRC="images/banner.gif"></A>
<P><STRONG>Click on the banner to return to the Class Reference home page.</STRONG></P>
<P>©Copyright 1996 Rogue Wave Software</P>
<H2>logical_not</H2>
<HR><PRE> Function<B><I> </I></B>Object</B></I>
</PRE><HR>
<A NAME="Summary"><H3>Summary</H3></A>
<P>Unary function object that returns <SAMP>true</SAMP> if its argument is <SAMP>false</SAMP>.</P>
<H3>Contents</H3>
<UL>
<A HREF="#Synopsis"><LI>Synopsis</LI></A>
<A HREF="#Description"><LI>Description</LI></A>
<A HREF="#Interface"><LI>Interface</LI></A>
<A HREF="#Warning"><LI>Warning</LI></A>
<A HREF="#See Also"><LI>See Also</LI></A>
</UL>
<A NAME="Synopsis"><H3>Synopsis</H3></A>
<PRE>#include <functional></PRE>
<PRE>
template <class T>
struct <B>logical_not</B> : unary_function<T, bool> ;
</PRE>
<A NAME="Description"><H3>Description</H3></A>
<P><B><I>logical_not</B></I> is a unary function object. Its <SAMP>operator()</SAMP> returns <SAMP>true</SAMP> if its argument is <SAMP>false</SAMP>. You can pass a <B><I>logical_not</B></I> object to any algorithm that requires a unary function. For example, the <A HREF="rep_6837.htm"><B><I>replace_if</B></I></A> algorithm replaces an element with another value if the result of a unary operation is true. <B><I>logical_not</B></I> is used in that algorithm in the following manner:</P>
<PRE>vector<int> vec1;</PRE>
<PRE>.
.
.
void replace_if(vec1.begin(), vec1.end(),
<B>logical_not<int>()</B>,1);
</PRE><P>This call to <A HREF="rep_6837.htm"><B><I>replace_if</B></I></A> replaces all zeros in the <SAMP>vec1</SAMP> with "1".</P>
<A NAME="Interface"><H3>Interface</H3></A>
<PRE>template <class T></PRE>
<PRE>struct logical_not : unary_function<T, bool> {
typedef typename unary_function<T, bool>::argument_type
argument_type;
typedef typename unary_function<T, bool>::result_type result_type;
bool operator() (const T&) const;
};
</PRE>
<A NAME="Warning"><H3>Warning</H3></A>
<P>If your compiler does not support default template parameters, you will need to always supply the <SAMP>Allocator</SAMP> template arguement. For instance, you will have to write :</P>
<P><SAMP>vector<int, allocator></SAMP></P>
<P>instead of : </P>
<P><SAMP>vector<int></SAMP></P>
<A NAME="See Also"><H3>See Also</H3></A>
<P><A HREF="Fun_7437.htm"><B><I>Function Objects</B></I></A>, <A HREF="una_4659.htm"><B><I>unary_function</B></I></A></P>
<HR>
<A HREF="log_2801.htm"><IMG SRC="images/prev.gif"></A> <A HREF="ref.htm#contents"><IMG SRC="images/toc.gif"></A> <A HREF="log_7695.htm"><IMG SRC="images/next.gif"></A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -