[問題] auto_ptr_ref的功用
請問auto_ptr的實作中為什麼要多定義
auto_ptr(auto_ptr_ref<T> rhs) throw() : ap(rhs.yp) {
}
auto_ptr& operator= (auto_ptr_ref<T> rhs) throw() { // new
reset(rhs.yp);
return *this;
}
template<class Y> operator auto_ptr_ref<Y>() throw() {
return auto_ptr_ref<Y>(release());
}
template<class Y> operator auto_ptr<Y>() throw() {
return auto_ptr<Y>(release());
}
其他的CODE的在http://www.josuttis.com/libbook/util/autoptr.hpp.html
看不太懂這些出現的時機。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.169.194.109
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章