Wikipedia:Articles for deletion/Mario Itzcoatl Quintanilla Nava and Auto ptr: Difference between pages

(Difference between pages)
Content deleted Content added
 
DanielKO (talk | contribs)
mNo edit summary
 
Line 1:
{{wrongtitle|title=auto_ptr}}
<div class="boilerplate metadata vfd" style="background-color: #F3F9FF; margin: 2em 0 0 0; padding: 0 10px 0 10px; border: 1px solid #AAAAAA;">
:''The following discussion is an archived debate of the proposed deletion of the article below. <font color=red>'''Please do not modify it.'''</font> Subsequent comments should be made on the appropriate discussion page (such as the article's talk page or on a [[Wikipedia:Deletion review|Deletion review]] nomination). No further edits should be made to this page. ''
<!--
Note: If you are seeing this page as a result of an attempt to re-nominate an article for deletion, you must manually edit the AfD nomination links in order to create a new discussion page using the name format of [[Wikipedia:Articles for deletion/PAGENAME (2nd nomination)]]. When you create the new discussion page, please provide a link to this old discussion in your nomination. -->
 
'''auto_ptr''' is a [[Template (programming) | template]] class available in the [[C_plus_plus|C++]] [[C Plus Plus standard library | Standard Library]] (declared in '''<memory>''') that provides some basic [[Resource Acquisition Is Initialization | RAII]] features for [[Pointers#C.2FC.2B.2B | C++ raw pointers]].
The result of the debate was '''Speedy delete''' as non-notable, though technically he does make a claim of notability ("Grand Prime Emperor of the Universe and its Surroundings") :). [[User:Thue|Thue]] | [[User talk:Thue|talk]] 09:57, 23 October 2005 (UTC)
 
== Definition ==
===[[Mario Itzcoatl Quintanilla Nava]]===
Obviously created as a joke. [[User:Superm401|Superm401]] | [[User_talk:Superm401|Talk]] 08:19, 23 October 2005 (UTC)
 
The auto_ptr class is defined in [[ISO/IEC 14882]], section 20.4.5 as:
*'''Delete''' nonsense - [[User:Cohesion|cohesion]] | [[User_talk:Cohesion|talk]] 08:26, 23 October 2005 (UTC)
* '''I''' am the Grand Prime Emperor of the Universe. '''Delete''' the imposter. [[User:TheMadBaron|TheMadBaron]] 08:30, 23 October 2005 (UTC)
* '''Speedy delete''' for vanity. -- [[User:SoothingR|SoothingR]] 09:36, 23 October 2005 (UTC)
 
namespace std {
template <class Y> struct auto_ptr_ref {};
template<class X>
class auto_ptr {
public:
typedef X element_type;
// 20.4.5.1 construct/copy/destroy:
explicit auto_ptr(X* p =0) throw();
auto_ptr(auto_ptr&) throw();
template<class Y> auto_ptr(auto_ptr<Y>&) throw();
auto_ptr& operator=(auto_ptr&) throw();
template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
auto_ptr& operator=(auto_ptr_ref<X> r) throw();
~auto_ptr() throw();
// 20.4.5.2 members:
X& operator*() const throw();
X* operator->() const throw();
X* get() const throw();
X* release() throw();
void reset(X* p =0) throw();
// 20.4.5.3 conversions:
auto_ptr(auto_ptr_ref<X>) throw();
template<class Y> operator auto_ptr_ref<Y>() throw();
template<class Y> operator auto_ptr<Y>() throw();
};
}
 
 
:''The above discussion is preserved as an archive of the debate. <font color=red>'''Please do not modify it.'''</font> Subsequent comments should be made on the appropriate discussion page (such as the article's talk page or in a [[Wikipedia:Deletion review|deletion review]]). No further edits should be made to this page.</div>
== Semantics ==
 
The auto_ptr has semantics of strict ownership, meaning that the auto_ptr instance is the sole responsible for the object's life-time. If an auto_ptr is copied, the source loses the reference. For example:
 
int *i = new int;
auto_ptr<int> x(i);
auto_ptr<int> y;
y = x;
cout << x.get() << endl;
cout << y.get() << endl;
 
This code will print a [[Null (Computer) | NULL]] reference for the first auto_ptr object and some address for the second, showing that the source object lost the reference during the assignment (''=''). The raw pointer ''i'' in the example should not be deleted, as it will be deleted by the auto_ptr that owns the reference.
 
Notice that the object pointed by an auto_ptr is destructed using ''operator delete''; this means that you should only use auto_ptr for pointers obtained with ''operator new''. This excludes pointers returned by [[malloc|malloc/calloc/realloc]] and ''operator new[]''.
 
 
{{uncategorized}}