Google C++ style guide's No-exceptions rule; STL?

后端 未结 8 1778
故里飘歌
故里飘歌 2020-12-08 01:56

Google\'s C++ style guide says \"We do not use exceptions\". The style does not mention STL with respect to usage of exception. Since STL allocators can fail, how do they ha

8条回答
  •  不知归路
    2020-12-08 02:28

    I have found that Google mentions this explicitly about STL and exceptions (emphasis is mine):

    Although you should not use exceptions in your own code, they are used extensively in the ATL and some STLs, including the one that comes with Visual C++. When using the ATL, you should define _ATL_NO_EXCEPTIONS to disable exceptions. You should investigate whether you can also disable exceptions in your STL, but if not, it is OK to turn on exceptions in the compiler. (Note that this is only to get the STL to compile. You should still not write exception handling code yourself.)

    I don't like such decisions (lucky that I am not working for Google), but they are quite clear about their behaviour and intentions.

提交回复
热议问题