以下はweak_ptrのコンストラクターの2つです:http: //msdn.microsoft.com/en-us/library/bb982126.aspx
weak_ptr(const weak_ptr&);
template<class Other>
weak_ptr(const weak_ptr<Other>&);
実際のコード(からmemory
):
weak_ptr(const weak_ptr& _Other)
{ // construct weak_ptr object for resource pointed to by _Other
this->_Resetw(_Other);
}
template<class _Ty2>
weak_ptr(const weak_ptr<_Ty2>& _Other,
typename enable_if<is_convertible<_Ty2 *, _Ty *>::value,
void *>::type * = 0)
{ // construct weak_ptr object for resource pointed to by _Other
this->_Resetw(_Other);
}
Q1:トップコピーコンストラクターがそこにあるのはなぜですか?下の方がすべてのケース(上の方を含む)を説明しているように見えます。それも呼ばれますか?そして、それらが含まれていなかった場合、一番下のものがその場所になりますか?
Q2:一番下の(テンプレート化された)コンストラクターの2番目の引数はどうなっていますか。SFINAEの側面は理解していると思いますが、なぜ余分な*が後にあるのかわかりません::type