forked from boostorg/smart_ptr
Clarify rationale for noncopyability
[SVN r10085]
This commit is contained in:
@@ -15,16 +15,21 @@ allocated array. (Dynamically allocated arrays are allocated with the C++ <tt>ne
|
|||||||
expression.) The array pointed to is guaranteed to be deleted,
|
expression.) The array pointed to is guaranteed to be deleted,
|
||||||
either on destruction of the <strong>scoped_array</strong>, or via an explicit <strong>scoped_array::reset()</strong>.</p>
|
either on destruction of the <strong>scoped_array</strong>, or via an explicit <strong>scoped_array::reset()</strong>.</p>
|
||||||
<p>Class<strong> scoped_array</strong> is a simple solution for simple
|
<p>Class<strong> scoped_array</strong> is a simple solution for simple
|
||||||
needs. It cannot be used in C++ Standard Library containers. See <a href="shared_array.htm"><strong>shared_array</strong></a>
|
needs. It supplies a basic "resource acquisition is
|
||||||
|
initialization" facility, without shared-ownership or transfer-of-ownership
|
||||||
|
semantics. Both its name and enforcement of semantics (by being <a href="../utility/utility.htm#class noncopyable">noncopyable</a>)
|
||||||
|
signal its intent to retain ownership solely within the current scope. By
|
||||||
|
being <a href="../utility/utility.htm#class noncopyable">noncopyable</a>, it is
|
||||||
|
safer than <b>shared_array</b> for pointers which should not be copied.</p>
|
||||||
|
<p>Because <strong>scoped_array</strong> is so simple, in its usual
|
||||||
|
implementation every operation is as fast as a built-in array pointer and it has no
|
||||||
|
more space overhead that a built-in array pointer.</p>
|
||||||
|
<p>It cannot be used in C++ Standard Library containers. See <a href="shared_array.htm"><strong>shared_array</strong></a>
|
||||||
if <strong>scoped_array</strong> does not meet your needs.</p>
|
if <strong>scoped_array</strong> does not meet your needs.</p>
|
||||||
<p>Class<strong> scoped_array</strong> cannot correctly hold a pointer to a
|
<p>Class<strong> scoped_array</strong> cannot correctly hold a pointer to a
|
||||||
single object. See <a href="scoped_ptr.htm"><strong>scoped_ptr</strong></a>
|
single object. See <a href="scoped_ptr.htm"><strong>scoped_ptr</strong></a>
|
||||||
for that usage.</p>
|
for that usage.</p>
|
||||||
<p>Because <strong>scoped_array</strong> is so simple, in its usual
|
<p>A C++ Standard Library <strong>vector</strong> is a <strong> </strong>heavier duty alternative to a <strong>scoped_array</strong>.</p>
|
||||||
implementation every operation is as fast as a built-in array pointer and has no
|
|
||||||
more space overhead that a built-in array pointer.</p>
|
|
||||||
<p>A heavier duty alternative to a <strong>scoped_array</strong> is a <strong>scoped_ptr</strong>
|
|
||||||
to a C++ Standard Library <strong>vector</strong>.</p>
|
|
||||||
<p>The class is a template parameterized on <tt>T</tt>, the type of the object
|
<p>The class is a template parameterized on <tt>T</tt>, the type of the object
|
||||||
pointed to. <tt>T</tt> must meet the smart pointer <a href="smart_ptr.htm#Common requirements">common
|
pointed to. <tt>T</tt> must meet the smart pointer <a href="smart_ptr.htm#Common requirements">common
|
||||||
requirements</a>.</p>
|
requirements</a>.</p>
|
||||||
|
@@ -16,14 +16,21 @@ expression.) The object pointed to is guaranteed to be deleted,
|
|||||||
either on destruction of the <strong>scoped_ptr</strong>, or via an explicit <strong>scoped_ptr::reset()</strong>.
|
either on destruction of the <strong>scoped_ptr</strong>, or via an explicit <strong>scoped_ptr::reset()</strong>.
|
||||||
See <a href="#scoped_ptr_example">example</a>.</p>
|
See <a href="#scoped_ptr_example">example</a>.</p>
|
||||||
<p>Class<strong> scoped_ptr</strong> is a simple solution for simple
|
<p>Class<strong> scoped_ptr</strong> is a simple solution for simple
|
||||||
needs. It cannot be used in C++ Standard Library containers. See <a href="shared_ptr.htm"><strong>shared_ptr</strong></a>
|
needs. It supplies a basic "resource acquisition is
|
||||||
|
initialization" facility, without shared-ownership or transfer-of-ownership
|
||||||
|
semantics. Both its name and enforcement of semantics (by being <a href="../utility/utility.htm#class noncopyable">noncopyable</a>)
|
||||||
|
signal its intent to retain ownership solely within the current scope. By
|
||||||
|
being <a href="../utility/utility.htm#class noncopyable">noncopyable</a>, it is
|
||||||
|
safer than <b>shared_ptr</b> or std::auto_ptr for pointers which should not be
|
||||||
|
copied.</p>
|
||||||
|
<p>Because <strong>scoped_ptr</strong> is so simple, in its usual implementation
|
||||||
|
every operation is as fast as for a built-in pointer and it has no more space overhead
|
||||||
|
that a built-in pointer.</p>
|
||||||
|
<p>Class<strong> scoped_ptr</strong> cannot be used in C++ Standard Library containers. See <a href="shared_ptr.htm"><strong>shared_ptr</strong></a>
|
||||||
or std::auto_ptr if <strong>scoped_ptr</strong> does not meet your needs.</p>
|
or std::auto_ptr if <strong>scoped_ptr</strong> does not meet your needs.</p>
|
||||||
<p>Class<strong> scoped_ptr</strong> cannot correctly hold a pointer to a
|
<p>Class<strong> scoped_ptr</strong> cannot correctly hold a pointer to a
|
||||||
dynamically allocated array. See <a href="scoped_array.htm"><strong>scoped_array</strong></a>
|
dynamically allocated array. See <a href="scoped_array.htm"><strong>scoped_array</strong></a>
|
||||||
for that usage.</p>
|
for that usage.</p>
|
||||||
<p>Because <strong>scoped_ptr</strong> is so simple, in its usual implementation
|
|
||||||
every operation is as fast as a built-in pointer and has no more space overhead
|
|
||||||
that a built-in pointer.</p>
|
|
||||||
<p>The class is a template parameterized on <tt>T</tt>, the type of the object
|
<p>The class is a template parameterized on <tt>T</tt>, the type of the object
|
||||||
pointed to. <tt>T</tt> must meet the smart pointer <a href="smart_ptr.htm#Common requirements">common
|
pointed to. <tt>T</tt> must meet the smart pointer <a href="smart_ptr.htm#Common requirements">common
|
||||||
requirements</a>.</p>
|
requirements</a>.</p>
|
||||||
@@ -116,7 +123,7 @@ body</code> is not visible at the time scoped_ptr<> deletes it. See ISO
|
|||||||
5.3.5/5. Note that some compilers will issue a warning even though the
|
5.3.5/5. Note that some compilers will issue a warning even though the
|
||||||
above code is well defined.</p>
|
above code is well defined.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B %Y" startspan -->27 July 2000<!--webbot bot="Timestamp" endspan i-checksum="18770" --></p>
|
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B %Y" startspan -->10 May 2001<!--webbot bot="Timestamp" endspan i-checksum="15101" --></p>
|
||||||
<p><EFBFBD> Copyright Greg Colvin and Beman Dawes 1999. Permission to copy, use,
|
<p><EFBFBD> Copyright Greg Colvin and Beman Dawes 1999. Permission to copy, use,
|
||||||
modify, sell and distribute this document is granted provided this copyright
|
modify, sell and distribute this document is granted provided this copyright
|
||||||
notice appears in all copies. This document is provided "as is"
|
notice appears in all copies. This document is provided "as is"
|
||||||
|
Reference in New Issue
Block a user