}throw;
A throw without following expression can be used inside an exception handler to re-throw the currently handled exception.
However, at this point your program does not have an active exception. In this case, throw calls std::terminate().
This seems to be an edit artifact.
solved Terminate called without an active exception : LeetCode Question 74 [closed]