【发布时间】:2014-01-22 02:02:48
【问题描述】:
我曾在 Visual C++ 中看到包含文件 <vector> 在函数后使用 throw():
size_type capacity() const _NOEXCEPT
{ // return current length of allocated storage
return (this->_Myend - this->_Myfirst);
}
_NOEXCEPT 是throw() 的宏,所以上面看起来像:
size_type capacity() const throw()
{ // return current length of allocated storage
return (this->_Myend - this->_Myfirst);
}
但是投掷有什么作用呢?我在this 中看到过问题,为什么这是一种不好的做法,但为什么在没有抛出或捕获的情况下将它放在那里?
【问题讨论】:
标签: c++ function throw noexcept