为什么 libc++ 没有实现 shared_ptr 的模板化移动赋值运算符 noexcept

问题描述

根据cppreference,shared_ptr 的模板化移动赋值运算符应该是noexceptLibstdc++ 实现了它,但 libc++ 没有实现。实际上,swap 成员函数和移动构造函数都是 noexcept。为什么?

template<class _Tp>
template<class _Yp>
inline
typename enable_if
<
    __compatible_with<_Yp,typename shared_ptr<_Tp>::element_type>::value,shared_ptr<_Tp>&
>::type
shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) // <--- not noexcept
{
    shared_ptr(_VSTD::move(__r)).swap(*this);
    return *this;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)