Reputation: 1089
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?
Upvotes: 4
Views: 2936
Reputation:
The throw exception specification is deprecated in C++11 and replaced by noexcept.
From http://en.cppreference.com/w/cpp/language/noexcept_spec:
noexcept is an improved version of throw(), which is deprecated in C++11. Unlike throw(), noexcept will not call std::unexpected and may or may not unwind the stack, which potentially allows the compiler to implement noexcept without the runtime overhead of throw().
Upvotes: 4