【发布时间】:2011-09-13 21:43:04
【问题描述】:
考虑一个带有副作用的复制构造函数的异常类。
编译器能否在此处跳过调用复制构造函数:
try {
throw ugly_exception();
}
catch(ugly_exception) // ignoring the exception, so I'm not naming it
{ }
这个呢:
try {
something_that_throws_ugly_exception();
}
catch(ugly_exception) // ignoring the exception, so I'm not naming it
{ }
(是的,我知道这一切都很丑陋,这是受到another question 的启发)
【问题讨论】:
标签: c++ exception optimization copy-elision