スローしないスワップ イディオムを実装する場合、使用する必要がありますthrow()
か?
namespace A
{
struct B
{
void swap( B& other ) throw()
{ /* fancy stuff that doesn't throw */ }
};
void swap( B& lhs, B& rhs ) throw()
{ lhs.swap(rhs); }
}
namespace std
{
template<>
void swap( A::B& lhs, A::B& rhs ) throw()
{ lhs.swap(rhs); }
}
throw()
特にの専門化に仕様を載せるのが気になりstd::swap
ます。
おまけの質問:
C++0x のnoexcept
キーワードを使用する場合、答えは異なりますか?