⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tim_4491.htm

📁 ARM编辑、编译软件
💻 HTM
字号:
<HTML><TITLE>times</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>&copy;Copyright 1996 Rogue Wave Software</P>
<H2>times</H2>
<HR><PRE>     Function Objec<B><I>t</B></I>
</PRE><HR>
<A NAME="Summary"><H3>Summary</H3></A>
<P>A binary function object that returns the result of multiplying its first and second arguments.</P>
<H3>Contents</H3>
<UL>
<A HREF="#Synopsis"><LI>Synopsis</LI></A>
<A HREF="#Description"><LI>Description</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&#60;functional></PRE>
<PRE>
template &#60;class T>
struct <B>times</B> : binary_function&#60;T, T, T> {
  typedef typename binary_function&#60;T, T, T>::second_argument_type  
                                             second_argument_type;
  typedef typename binary_function&#60;T, T, T>::first_argument_type 
                                             first_argument_type;
  typedef typename binary_function&#60;T, T, T>::result_type result_type;
  T operator() (const T&#38;, const T&#38;) const;
};
</PRE>
<A NAME="Description"><H3>Description</H3></A>
<P><B><I>times</B></I> is a binary function object.  Its <SAMP>operator()</SAMP> returns the result of multiplying <SAMP>x</SAMP> and <SAMP>y</SAMP>.  You can pass a <B><I>times</B></I> object to any algorithm that uses 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>times</B></I> would be used in that algorithm in the following manner:</P>
<PRE>vector&#60;int> vec1;
vector&#60;int> vec2;
vector&#60;int> vecResult;
.
.
.
transform(vec1.begin(), vec1.end(),          vec2.begin(), vec2.end(),
          vecResult.begin(), <B>times&#60;int>()</B>);</PRE>
<PRE></PRE><P>After this call to <A HREF="tra_4787.htm"><B><I>transform</B></I></A>, <SAMP>vecResult(n)</SAMP> will contain <SAMP>vec1(n)</SAMP> times <SAMP>vec2(n)</SAMP>.</P>
<A NAME="Warning"><H3>Warning</H3></A>
<P>If your compiler does not support default template parameters, then you need to always supply the <SAMP>Allocator</SAMP> template argument.  For instance, you will have to write :</P>
<P><SAMP>vector&#60;int, allocator></SAMP></P>
<P>instead of :</P>
<P><SAMP>vector&#60;int></SAMP></P>
<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="swa_1153.htm"><IMG SRC="images/prev.gif"></A> <A HREF="ref.htm#contents"><IMG SRC="images/toc.gif"></A> <A HREF="tra_4787.htm"><IMG SRC="images/next.gif"></A></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -