what does this declaration mean? exception() throw()

后端 未结 5 1219
暗喜
暗喜 2021-01-12 05:34

std::exception class is defined as follows

exception() throw() { }
virtual ~exception() throw();
virtual const char* what() const throw();

5条回答
  •  爱一瞬间的悲伤
    2021-01-12 05:43

    It's an "exception specification". throw() means "this function will not throw any exceptions". You can also specify exceptions, so throw(foo) would say this function may throw exceptions of type foo.

    The usefulness of this feature has been debated quite a bit in the C++ community - the general evaluation seems to be that it is not particularly useful. For more details take a look at this Herb Sutter article.

提交回复
热议问题