聲明從C++標準庫空結構背後的目的是什麼?的auto_ptr
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>) 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();
};
}
我不明白,這部分的目的:
template <class Y> struct auto_ptr_ref {};
沒有宣佈任何變量,如何能夠將這些有效:
auto_ptr& operator=(auto_ptr_ref<X>) throw();
這些也是:
auto_ptr(auto_ptr_ref<X>) throw();
template <class Y> operator auto_ptr_ref<Y>() throw();
編輯:也(我注意到),我不知道如何「操作員」用於最後兩行。是不是語法像「返回類型operatoroperand;」,其中是返回類型?操作數?
啊我根本就不知道那個雖然(這裏還是新手) – user385261 2010-07-23 09:09:54
@ user385261:當你是一個網站的新手時,請閱讀他們的FAQ。這不是踢腿。 – 2011-09-09 09:17:43