mercredi 21 avril 2021

Why isn't the libc++'s implementation of the shared_ptr's templated move assignment operator noexcept

According to cppreference, the shared_ptr's templated move assignment operator should be noexcept. Libstdc++ implements it, but libc++ doesn't. Actually, both the swap member function and the move constructor are noexcept. Why?

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;
}

Aucun commentaire:

Enregistrer un commentaire