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

📄 memory.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
📖 第 1 页 / 共 2 页
字号:
    };</PRE><P>The class describes an object that stores a pointer to an allocated object<B><CODE>myptr</CODE></B> of type <CODE>Ty *</CODE>. The stored pointer must either be null ordesignate an object allocated by a<CODE>new</CODE> expression.An object constructed with a non-null pointer owns the pointer.It transfers ownership if its stored value is assigned to anotherobject. (It replaces the stored value after a transfer with a null pointer.)The destructor for <CODE>auto_ptr&lt;Ty&gt;</CODE>deletes the allocated object if it owns it.Hence, an object of class <CODE>auto_ptr&lt;Ty&gt;</CODE>ensures that an allocated object is automatically deleted whencontrol leaves a block, even via a thrown excepiton.You should not construct two <CODE>auto_ptr&lt;Ty&gt;</CODE> objectsthat own the same object.</P><P>You can pass an <CODE>auto_ptr&lt;Ty&gt;</CODE> object by value as anargument to a function call. You can return such an object by value as well.(Both operations depend on the implicit construction of intermediate objectsof class <CODE>auto_ptr_ref&lt;Ty&gt;</CODE>, by varioussubtle conversion rules.) You cannot, however, reliably manage a sequence of<CODE>auto_ptr&lt;Ty&gt;</CODE> objects with an STL<A HREF="lib_cont.html#Containers">container</A>.</P><H3><A NAME="auto_ptr::auto_ptr"><CODE>auto_ptr::auto_ptr</CODE></A></H3><PRE>explicit <B>auto_ptr</B>(Ty *ptr = 0) throw();<B>auto_ptr</B>(auto_ptr&lt;Ty&gt;&amp; right) throw();<B>auto_ptr</B>(auto_ptr_ref&lt;Ty&gt; right) throw();template&lt;class Other&gt;    <B>auto_ptr</B>(auto_ptr&lt;Other&gt;&amp; right) throw();</PRE><P>The first constructor stores <CODE>ptr</CODE> in <CODE>myptr</CODE>,the stored pointer to the allocated object.The second constructor transfers ownership of thepointer stored in <CODE>right</CODE>, by storing<CODE>right.<A HREF="#auto_ptr::release">release</A>()</CODE>in <CODE>myptr</CODE>.The third constructor behaves the same as the second, exceptthat it stores <CODE>right.ref.release()</CODE> in <CODE>myptr</CODE>, where <CODE>ref</CODE>is the reference stored in <CODE>right</CODE>.</P><P>The template constructor behaves the same as the second constructor,provided that a pointer to <CODE>Other</CODE> can be implicitly convertedto a pointer to <CODE>Ty</CODE>.</P><H3><A NAME="auto_ptr::~auto_ptr"><CODE>auto_ptr::~auto_ptr</CODE></A></H3><PRE><B>~auto_ptr</B>();</PRE><P>The destructor evaluates the expression <CODE>delete myptr</CODE>to delete the object designated by the stored pointer.</P><H3><A NAME="auto_ptr::element_type"><CODE>auto_ptr::element_type</CODE></A></H3><PRE>typedef Ty <B>element_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Ty</CODE>.</P><H3><A NAME="auto_ptr::get"><CODE>auto_ptr::get</CODE></A></H3><PRE>Ty *<B>get</B>() const throw();</PRE><P>The member function returns the stored pointer <CODE>myptr</CODE>.</P><H3><A NAME="auto_ptr::operator="><CODE>auto_ptr::operator=</CODE></A></H3><PRE>template&lt;class Other&gt;    auto_ptr&lt;Ty&gt;&amp; <B>operator=</B>(auto_ptr&lt;Other&gt;&amp; right) throw();auto_ptr&lt;Ty&gt;&amp; <B>operator=</B>(auto_ptr&lt;&gt;&amp; right) throw();</PRE><P>The assignment evaluates the expression <CODE>delete myptr</CODE>,but only if the stored pointer <CODE>myptr</CODE>changes as a result of the assignment.It then transfers ownership of the pointer stored in <CODE>right</CODE>, by storing<CODE>right.<A HREF="#auto_ptr::release">release</A>()</CODE> in <CODE>myptr</CODE>.The function returns <CODE>*this</CODE>.</P><H3><A NAME="auto_ptr::operator*"><CODE>auto_ptr::operator*</CODE></A></H3><PRE>Ty&amp; <B>operator*</B>() const throw();</PRE><P>The indirection operator returns<CODE>*<A HREF="#auto_ptr::get">get</A>()</CODE>.Hence, the stored pointer must not be null.</P><H3><A NAME="auto_ptr::operator-&gt;"><CODE>auto_ptr::operator-&gt;</CODE></A></H3><PRE>Ty *<B>operator-&gt;</B>() const throw();</PRE><P>The selection operator returns<CODE><A HREF="#auto_ptr::get">get</A>()</CODE>,so that the expression <CODE>ap-&gt;member</CODE> behaves the same as<CODE>(ap.get())-&gt;member</CODE>, where <CODE>ap</CODE> is an objectof class <CODE>auto_ptr&lt;Ty&gt;</CODE>.Hence, the stored pointer must not be null, and <CODE>Ty</CODE>must be a class, structure, or union type with a member <CODE>member</CODE>.</P><H3><A NAME="auto_ptr::operator auto_ptr&lt;Other&gt;"><CODE>auto_ptr::operator auto_ptr&lt;Other&gt;</CODE></A></H3><PRE>template&lt;class Other&gt;    <B>operator auto_ptr&lt;Other&gt;</B>() throw();</PRE><P>The type cast operator returns<CODE>auto_ptr&lt;Other&gt;(*this)</CODE>.</P><H3><A NAME="auto_ptr::operator auto_ptr_ref&lt;Other&gt;"><CODE>auto_ptr::operator auto_ptr_ref&lt;Other&gt;</CODE></A></H3><PRE>template&lt;class Other&gt;    <B>operator auto_ptr_ref&lt;Other&gt;</B>() throw();</PRE><P>The type cast operator returns<CODE><A HREF="#auto_ptr_ref">auto_ptr_ref</A>&lt;Other&gt;(*this)</CODE>.</P><H3><A NAME="auto_ptr::release"><CODE>auto_ptr::release</CODE></A></H3><PRE>Ty *<B>release</B>() throw();</PRE><P>The member replaces the stored pointer <CODE>myptr</CODE> with a null pointer andreturns the previously stored pointer.</P><H3><A NAME="auto_ptr::reset"><CODE>auto_ptr::reset</CODE></A></H3><PRE>void <B>reset</B>(Ty *ptr = 0);</PRE><P>The member function evaluates the expression <CODE>delete myptr</CODE>,but only if the stored pointer value <CODE>myptr</CODE>changes as a result of function call.It then replaces the stored pointer with <CODE>ptr</CODE>.</P><H2><A NAME="auto_ptr_ref"><CODE>auto_ptr_ref</CODE></A></H2><PRE>template&lt;class Ty&gt;    struct <B>auto_ptr_ref</B> {    auto_ptr_ref(auto_ptr&lt;Ty&gt;&amp; right);    };</PRE><P>The class describes an object that stores a reference to an object of class<CODE><A HREF="#auto_ptr">auto_ptr</A>&lt;Ty&gt;</CODE>. It is used as a helperclass for <CODE>auto_ptr&lt;Ty&gt;</CODE>. You should not have an occasionto construct an <CODE>auto_ptr_ref&lt;Ty&gt;</CODE> object directly.</P><H2><A NAME="get_temporary_buffer"><CODE>get_temporary_buffer</CODE></A></H2><PRE>template&lt;class Ty&gt;    pair&lt;Ty *, ptrdiff_t&gt;        <B>get_temporary_buffer</B>(ptrdiff_t count);</PRE><P>The template function allocates storage for a sequence of at most<CODE>count</CODE> elements of type <CODE>Ty</CODE>, from an unspecifiedsource (which may well be the standard heap used by<CODE>operator new</CODE>).It returns a value <CODE>pr</CODE>, of type<CODE><A HREF="utility.html#pair">pair</A>&lt;Ty *, ptrdiff_t&gt;</CODE>.If the function allocates storage,<CODE>pr.<A HREF="utility.html#pair::first">first</A></CODE> designatesthe allocated storage and<CODE>pr.<A HREF="utility.html#pair::second">second</A></CODE>is the number of elements in the longest sequence the storage can hold.Otherwise, <CODE>pr.first</CODE> is a null pointer.</P><P>In this <A HREF="index.html#implementation">implementation</A>,if a translator does not support member template functions, the template:</P><PRE>template&lt;class Ty&gt;    pair&lt;Ty *, ptrdiff_t&gt;        <B>get_temporary_buffer</B>(ptrdiff_t count);</PRE><P>is replaced by:</P><PRE>template&lt;class Ty&gt;    pair&lt;Ty *, ptrdiff_t&gt;        <B>get_temporary_buffer</B>(ptrdiff_t count, Ty *);</PRE><H2><A NAME="operator!="><CODE>operator!=</CODE></A></H2><PRE>template&lt;class Ty&gt;    bool <B>operator!=</B>(allocator&lt;Ty&gt;&amp; left,        allocator&lt;Ty&gt;&amp; right) throw();</PRE><P>The template operator returns false.</P><H2><A NAME="operator=="><CODE>operator==</CODE></A></H2><PRE>template&lt;class Ty&gt;    bool <B>operator==</B>(allocator&lt;Ty&gt;&amp; left,        allocator&lt;Ty&gt;&amp; right) throw();</PRE><P>The template operator returns true. (Two allocator objects shouldcompare equal only if an object allocated through one can be deallocatedthrough the other. If the value of one object is determined from anotherby assignment or by construction, the two object should compare equal.)</P><H2><A NAME="raw_storage_iterator"><CODE>raw_storage_iterator</CODE></A></H2><PRE>template&lt;class FwdIt, class Ty&gt;    class <B>raw_storage_iterator</B>         : public iterator&lt;output_iterator_tag,             void, void, void, void&gt; {public:    typedef FwdIt <B><A HREF="#raw_storage_iterator::iter_type">iter_type</A></B>;    typedef Ty <B><A HREF="#raw_storage_iterator::element_type">element_type</A></B>;    explicit <B><A HREF="#raw_storage_iterator::raw_storage_iterator">raw_storage_iterator</A></B>(FwdIt first);    raw_storage_iterator&lt;FwdIt, Ty&gt;&amp; <B><A HREF="#raw_storage_iterator::operator*">operator*</A></B>();    raw_storage_iterator&lt;FwdIt, Ty&gt;&amp;        <B><A HREF="#raw_storage_iterator::operator=">operator=</A></B>(const Ty&amp; val);    raw_storage_iterator&lt;FwdIt, Ty&gt;&amp; <B><A HREF="#raw_storage_iterator::operator++">operator++</A></B>();    raw_storage_iterator&lt;FwdIt, Ty&gt; <B><A HREF="#raw_storage_iterator::operator++">operator++</A></B>(int);    };</PRE><P>The class describes an output iteratorthat constructs objects of type <CODE>Ty</CODE>in the sequence it generates. An object of class<CODE>raw_storage_iterator&lt;FwdIt, Ty&gt;</CODE>accesses storage through a forward iterator object,of class <CODE>FwdIt</CODE>, that you specify when you constructthe object. For an object <CODE>first</CODE> of class <CODE>FwdIt</CODE>,the expression <CODE>&*first</CODE> must designate unconstructed storage forthe next object (of type <CODE>Ty</CODE>) in the generated sequence.</P><H3><A NAME="raw_storage_iterator::element_type"><CODE>raw_storage_iterator::element_type</CODE></A></H3><PRE>typedef Ty <B><A HREF="#raw_storage_iterator::element_type">element_type</A></B>;</PRE><P>The type is a synonym for the template parameter <CODE>Ty</CODE>.</P><H3><A NAME="raw_storage_iterator::iter_type"><CODE>raw_storage_iterator::iter_type</CODE></A></H3><PRE>typedef FwdIt <B><A HREF="#raw_storage_iterator::iter_type">iter_type</A></B>;</PRE><P>The type is a synonym for the template parameter <CODE>FwdIt</CODE>.</P><H3><A NAME="raw_storage_iterator::operator*"><CODE>raw_storage_iterator::operator*</CODE></A></H3><PRE>raw_storage_iterator&lt;FwdIt, Ty&gt;&amp; <B>operator*</B>();</PRE><P>The indirection operator returns <CODE>*this</CODE> (so that<CODE><A HREF="#raw_storage_iterator::operator=">operator=</A>(constTy&amp;)</CODE> can perform the actual storein an expression such as <CODE>*ptr = val</CODE>).</P><H3><A NAME="raw_storage_iterator::operator="><CODE>raw_storage_iterator::operator=</CODE></A></H3><PRE>raw_storage_iterator&lt;FwdIt, Ty&gt;&amp; <B>operator=</B>(const Ty&amp; val);</PRE><P>The assignment operator constructs the next object in theoutput sequence using the stored iterator value <CODE>first</CODE>,by evaluating theplacement <CODE>new</CODE> expression<CODE>new ((void *)&amp;*first) Ty(val)</CODE>.The function returns <CODE>*this</CODE>.</P><H3><A NAME="raw_storage_iterator::operator++"><CODE>raw_storage_iterator::operator++</CODE></A></H3><PRE>raw_storage_iterator&lt;FwdIt, Ty&gt;&amp; <B>operator++</B>();raw_storage_iterator&lt;FwdIt, Ty&gt; <B>operator++</B>(int);</PRE><P>The first (preincrement) operator increments the stored output iteratorobject, then returns <CODE>*this</CODE>.</P><P>The second (postincrement) operator makes a copy of <CODE>*this</CODE>,increments the stored output iterator object, then returnsthe copy.</P><H3><A NAME="raw_storage_iterator::raw_storage_iterator"><CODE>raw_storage_iterator::raw_storage_iterator</CODE></A></H3><PRE>explicit <B>raw_storage_iterator</B>(FwdIt first);</PRE><P>The constructor stores <CODE>first</CODE> as the output iteratorobject.</P><H2><A NAME="return_temporary_buffer"><CODE>return_temporary_buffer</CODE></A></H2><PRE>template&lt;class Ty&gt;    void <B>return_temporary_buffer</B>(Ty *pbuf);</PRE><P>The template function frees the storage designated by <CODE>pbuf</CODE>,which must be earlier allocated by a call to<CODE><A HREF="#get_temporary_buffer">get_temporary_buffer</A></CODE>.</P><H2><A NAME="uninitialized_copy"><CODE>uninitialized_copy</CODE></A></H2><PRE>template&lt;class InIt, class FwdIt&gt;    FwdIt <B>uninitialized_copy</B>(InIt first, InIt last,        FwdIt dest);</PRE><P>The template function effectively executes:</P><PRE>while (first != last)    new ((void *)&amp;*dest++)        iterator_traits&lt;InIt&gt;::<A HREF="iterator.html#iterator_traits::value_type">value_type</A>(*first++);return first;</PRE><P>unless the code throws an exception. In that case, allconstructed objects are destroyed and the exception is rethrown.</P><H2><A NAME="uninitialized_fill"><CODE>uninitialized_fill</CODE></A></H2><PRE>template&lt;class FwdIt, class Ty&gt;    void <B>uninitialized_fill</B>(FwdIt first, FwdIt last,        const Ty&amp; val);</PRE><P>The template function effectively executes:</P><PRE>while (first != last)    new ((void *)&amp;*first++)        iterator_traits&lt;FwdIt&gt;::<A HREF="iterator.html#iterator_traits::value_type">value_type</A>(val);</PRE><P>unless the code throws an exception. In that case, allconstructed objects are destroyed and the exception is rethrown.</P><H2><A NAME="uninitialized_fill_n"><CODE>uninitialized_fill_n</CODE></A></H2><PRE>template&lt;class FwdIt, class Size, class Ty&gt;    void <B>uninitialized_fill_n</B>(FwdIt first, Size count,        const Ty&amp; val);</PRE><P>The template function effectively executes:</P><PRE>while (0 &lt; count--)    new ((void *)&amp;*first++)        iterator_traits&lt;FwdIt&gt;::<A HREF="iterator.html#iterator_traits::value_type">value_type</A>(val);</PRE><P>unless the code throws an exception. In that case, allconstructed objects are destroyed and the exception is rethrown.</P><HR><P>See also the<B><A HREF="index.html#Table of Contents">Table of Contents</A></B> and the<B><A HREF="_index.html">Index</A></B>.</P><P><I><A HREF="crit_pjp.html">Copyright</A> &#169; 1994-2002by P.J. Plauger. Portions derived from work<A HREF="crit_hp.html">copyright</A> &#169; 1994by Hewlett-Packard Company. All rights reserved.</I></P><!--V4.01:1125--></BODY></HTML>

⌨️ 快捷键说明

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