コピーエリジョンはキャッチステートメントで発生する可能性がありますか?

StackOverflow https://stackoverflow.com/questions/7401521

質問

副作用を備えたコピーコンストラクターを備えた例外クラスを検討してください。

ここでコピーコンストラクターを呼び出すコンパイラをスキップできますか:

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
{ }

(はい、私はこれがすべて非常に醜いことを知っています、これはに触発されました 別の質問)

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top