これはより適切な質問だと思ったので、タイトルを少し変更しました。
リファクタリングしますか (goto の正当な使用のようです) ? 次のコードをどのようにリファクタリングして go to ステートメントを削除しますか?
if (data.device) {
try {
...
}
catch(const std::exception&) { goto done; }
... // more things which should not be caught
done: ;
}
完全なステートメント
#ifdef HAVE_GPU
// attempt to use GPU device
if (data.device) {
try {
Integral::Gpu eri(S, R, Q, block.shell());
eri(basis.centers(), quartets, data.device);
}
// if GPU fails, propagate to cpu
catch(std::exception) { goto done; }
data.device += size;
host_index.extend(block_index);
block_index.data.clear();
done: ;
}
#endif
ありがとうございました
ほとんどの好みを見た後、フラグで行くことにしましたが、ヨーク氏のコメントで。
みんなありがとう