我试图理解为什么 std::make_shared 是这样声明/实现的:
template<class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
!is_array<_Tp>::value,
shared_ptr<_Tp>
>::type
make_shared(_Args&& ...__args)
{
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
}
我很好奇的是:
- 为什么
make_shared只接受右值引用?为什么引用常量(即 )没有重载const _Args &? - 打电话的意义
_VSTD::forward何在?
好的解释或好的超链接都将受到高度赞赏。