In a game or some other application where an infinite loop would be used, could wrapping the loop in a try
-catch
block be a detriment to performance?
Something like this:
auto main() -> int{
game::init();
try{
while(1){
some_func();
some_other_func();
if(breaking_func())
break;
something_that_could_throw(); // unlikely, though
draw();
swap_buffers();
}
}
catch(const std::exception &err){
// do error handling
}
game::cleanup();
}
I tagged gcc
, but any other compilers would also be applicable.