catching exception objects by reference, temporaries, lifetime issues

前端 未结 4 874
独厮守ぢ
独厮守ぢ 2021-01-13 03:55

Consider the following code:

#include 
#include 

void foo()
{
    throw std::runtime_error(\"How long do I live?\");
}

int         


        
4条回答
  •  半阙折子戏
    2021-01-13 04:13

    As Neil said, there is internal compiler magic going on. Also, be aware that the compiler is allowed to create any number of copies of the exception object.

提交回复
热议问题