libstdc++'s optional::swap reads as follows:
void
swap(optional& __other)
noexcept(is_nothrow_move_constructible<_Tp>()
&& noexcept(swap(declval<_Tp&>(), declval<_Tp&>())))
{
When compiling with clang, it complains that swap() (called from the
noexcept operator) accepts only one argument. Isn't it correct?
shouldn't single-argument member swap() hide the two-argument non-member
swap?
A few lines below, libstdc++ continues:
using std::swap;
if (this->_M_is_engaged() && __other._M_is_engaged())
swap(this->_M_get(), __other._M_get());
else if (this->_M_is_engaged())
{
__other._M_construct(std::move(this->_M_get()));
this->_M_destruct();
}
else if (__other._M_is_engaged())
{
this->_M_construct(std::move(__other._M_get()));
__other._M_destruct();
}
}
So it's explicitly bringing std::swap into scope here, but it's too late
for the expression in the noexcept operator.
Is this a bug in libstdc++ (and in gcc for not detecting it), or in clang?