namespace std{
template<class Y>
struct auto_ptr_ref
{
Y* yp;
auto_ptr_ref(Y* rhs) :yp(rhs){
}
};
template<class T>
class auto_ptr{
private:
T* ap;
public:
typedef T element_type;
explicit auto_ptr(T* ptr = 0)throw() :ap(ptr){
}
auto_ptr(auto_ptr& rhs)throw():ap(rhs.release()){}
template<class Y>
auto_ptr(auto_ptr<Y>& rhs)throw():ap(rhs.rekease()){
}
auto_ptr& operator=(auto_ptr& rhs)throw(){
reset(rhs.release());
return *this;
}
template<class Y>
auto_ptr& operator=(auto_ptr<Y>& rhs)throw(){
reset(rhs.release());
return *this;
}
~auto_ptr()throw(){
delete ap;
}
T* Get() const throw(){
return ap;
}
T& operator*()const throw(){
return *ap;
}
T* operator->()const throw(){
return ap;
}
\
T* release()throw(){
T* tmp(ap);
ap = 0;
return tmp;
}
};
}
template<class Y>
struct auto_ptr_ref
{
Y* yp;
auto_ptr_ref(Y* rhs) :yp(rhs){
}
};
template<class T>
class auto_ptr{
private:
T* ap;
public:
typedef T element_type;
explicit auto_ptr(T* ptr = 0)throw() :ap(ptr){
}
auto_ptr(auto_ptr& rhs)throw():ap(rhs.release()){}
template<class Y>
auto_ptr(auto_ptr<Y>& rhs)throw():ap(rhs.rekease()){
}
auto_ptr& operator=(auto_ptr& rhs)throw(){
reset(rhs.release());
return *this;
}
template<class Y>
auto_ptr& operator=(auto_ptr<Y>& rhs)throw(){
reset(rhs.release());
return *this;
}
~auto_ptr()throw(){
delete ap;
}
T* Get() const throw(){
return ap;
}
T& operator*()const throw(){
return *ap;
}
T* operator->()const throw(){
return ap;
}
\
T* release()throw(){
T* tmp(ap);
ap = 0;
return tmp;
}
};
}