C++ Error: terminating with uncaught exception of type std::out_of_range: vector Abort trap: 6

Toss about for a long time, finally clear the specific reason!
According to the exception prompt, vector is out of bounds, but it has not been located to which vector variable for a long time.
Write the class printf before and after the interrupt position, find the interrupted function, and print inside the function, only to find that the function doesn’t go in at all. It’s strange how you can’t go back in, no other thread, no other place to cause a crash. At this point, I should have thought to check the input of the function earlier. If the input is not correct, the function cannot enter. However, I have never encountered the situation that the input causes the function to not enter, so I did not think to check the input.
The input is a vector type, and the error is due to a problem with the access method.
Vector has a variety of access methods, which can be accessed directly in the way of array, such as VEC variable, VEC [0], or at(), vec.AT (0). There are differences between the two approaches. If veC happens to be empty, accessing the 0th element as an array will not be considered wrong, but the second access using the at method will result in the above error!!

Read More: