在实现非抛出交换习语时,我应该使用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关键字时答案是否不同?