c++ - rewrite throw after function with noexcept -
i have heard in c++11 should replace throw noexcept after method declaration :
in c++11, should use noexcept instead. old throw specification deprecated.
how in following code?
template <typename object> class stack { public: stack(); object & peek() throw(std::runtime_error); }; reference link
please avoid linking questions not work std::runtime_error
it found dynamic exception specifications not useful, why they've been deprecated in c++11. case deemed useful empty dynamic exception specification, throw(). case, noexcept declaration introduced better alternative, allowing compiler perform more aggressive optimizations. (note means throw() , noexcept not semantically equivalent , should replace former latter if know program still behave correctly.)
in case, don't have empty throw() cannot replace noexcept. agreed upon in case, best remove throw(std::runtime_error) , mention fact function might throw std::runtime_error nothing else in documentation, yakk has suggested in comments.
Comments
Post a Comment