I have seen in the Visual C++ include file <vector>
using throw()
after a function:
size_type capacity() const _NOEXCEPT
{ // return current length of allocated storage
return (this->_Myend - this->_Myfirst);
}
With the _NOEXCEPT
a macro for throw()
, so the above looks like:
size_type capacity() const throw()
{ // return current length of allocated storage
return (this->_Myend - this->_Myfirst);
}
But what does the throw do? I have seen in this question why it is a bad practise, but why has it been put there when nothing is thrown or caught?
The throw exception specification is deprecated in C++11 and replaced by noexcept.
From http://en.cppreference.com/w/cpp/language/noexcept_spec: