我正在读取enable_shared_from_this的stl代码,它位于gcc-4.9.2 \ libstdC++ - v3 \ include \ bits \ shared_ptr.h中。然后我看到这一点:为什么在__enable_shared_from_this_helper中没有模板参数在gcc/libstdC++
template<typename _Tp1>
friend void
__enable_shared_from_this_helper(const __shared_count<>& __pn,
const enable_shared_from_this* __pe,
const _Tp1* __px) noexcept
{
if (__pe != 0)
__pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn);
}
我的问题是,为什么没有为常量模板参数enable_shared_from_this * __pe?当shared_ptr构造函数使用指向A类的指针调用__enable_shared_from_this_helper时,它如何工作,其中A是从enable_shared_from_this派生的?