Albania (placename) and Auto ptr: Difference between pages

(Difference between pages)
Content deleted Content added
rv - Greek propaganda
 
DanielKO (talk | contribs)
mNo edit summary
 
Line 1:
{{wrongtitle|title=auto_ptr}}
The name '''[[Albania]]''' probably derives from the same source as the name of the [[Alps]], the etymology of which is disputed [http://www.etymonline.com/index.php?search=Alps&searchnode=none]. Like the [[Alps]], the ultimate source of ''Albania'' is unknown. It may derive from the [[Proto-Indo-European]] root ''*albho-'', which meant '[[white]]'; referring perhaps to the snow-capped mountains of [[Albania]]. Others think the source may be a non-Indo-European root ''*alb-'', meaning '[[mountain]]', although this non-Indo-European root is much more hypothetical than the Indo-European root which can be said to have certainly existed. Another idea is that ''Albania'' derives from [[Proto-Indo-European|PIE]] ''*al-'', 'to grow, nourish', from which comes [[Latin]] ''altus'', 'high, elevated'.
 
'''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]].
''Albania'' is the name of a country in [[Europe]] as well as the name of an ancient land in the [[Caucasus]] (see [[Caucasian Albania]]) and also name for [[Scotland]] in Gaelic. The [[Illyrian]] ethnonym ''Albanoi'' was derived from the same source as ''Albania'', as is the modern ethnonym ''[[Albanian]]''. The mediaeval ethnonyms ''Arbanitai'' and ''Arbanios'' and the corresponding modern ethnonyms ''[[Arvanite]]'', ''Arber'', and ''[[Arbëreshë]]'' are also considered to derive from ''Albania'' by way of a [[rhotacism]] (compare the rhotacism of ''alb-'' into ''arv-'' in the [[Neapolitan language|Neapolitan]] dialect of [[Italy]]).
 
== Definition ==
{{albania-stub}}
 
The auto_ptr class is defined in [[ISO/IEC 14882]], section 20.4.5 as:
[[Category:History of Albania]]
 
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();
};
}
 
 
== 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}}