📄 equ_8796.htm
字号:
<HTML><TITLE>equal_to</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>equal_to</H2>
<HR><PRE> Function Object</PRE><HR>
<A NAME="Summary"><H3>Summary</H3></A>
<P>Binary function object that returns <SAMP>true</SAMP> if its first argument equals its second</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="#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> equal_to;</B>
</PRE>
<A NAME="Description"><H3>Description</H3></A>
<P><B><I>equal_to</B></I> is a binary function object. Its <SAMP>operator()</SAMP> returns <SAMP>true</SAMP> if <SAMP>x</SAMP> is equal to <SAMP>y</SAMP>. You can pass an <B><I>equal_to</B></I> object to any algorithm that requires a binary function. For example, the <A HREF="tra_4787.htm"><B><I>transform</B></I></A> algorithm applies a binary operation to corresponding values in two collections and stores the result. <B><I>equal_to</B></I> would be used in that algorithm in the following manner:</P>
<PRE>vector<int> vec1;</PRE>
<PRE>vector<int> vec2;
vector<int> vecResult;
.
.
.
transform(vec1.begin(), vec1.end(),
vec2.begin(), vecResult.begin(),
<B>equal_to</B><int>());
</PRE><P>After this call to <A HREF="tra_4787.htm"><B><I>transform</B></I></A>, <SAMP>vecResult(n)</SAMP> will contain a "1" if <SAMP>vec1(n)</SAMP> was equal to <SAMP>vec2(n)</SAMP> or a "0" if <SAMP>vec1(n)</SAMP> was not equal to <SAMP>vec2(n)</SAMP>.</P>
<A NAME="Interface"><H3>Interface</H3></A>
<PRE>template <class T></PRE>
<PRE> struct<B> equal_to </B>: binary_function<T, T, bool>
{
typedef typename binary_function<T, T, bool>::second_argument_type
second_argument_type;
typedef typename binary_function<T, T, bool>::first_argument_type
first_argument_type;
typedef typename binary_function<T, T, bool>::result_type
result_type;
bool operator() (const T&, const T&) const;
};</PRE>
<A NAME="See Also"><H3>See Also</H3></A>
<P><A HREF="bin_7851.htm"><B><I>binary_function</B></I></A>, <A HREF="Fun_7437.htm"><B><I>Function Objects</B></I></A></P>
<HR>
<A HREF="equ_3232.htm"><IMG SRC="images/prev.gif"></A> <A HREF="ref.htm#contents"><IMG SRC="images/toc.gif"></A> <A HREF="exc_9785.htm"><IMG SRC="images/next.gif"></A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -