std::out_of_range: "basic_string::substr: __pos (which is 4) > this->size() (which is 0)" Error Solution
This error message is indicating that your code is trying to access a substring of a string that is out of range.\n\nIn this specific case, the error is caused by trying to call the substr function on an empty string (this->size() returns 0), but specifying a starting position of 4 (__pos is 4). Since the string is empty, any starting position greater than 0 will be out of range, resulting in the error.\n\nTo fix this issue, you need to ensure that the string you are working with is not empty before calling substr. You can do this by checking the size of the string before calling the function or by using an if statement to handle the empty string case separately.
原文地址: https://www.cveoy.top/t/topic/pHQ4 著作权归作者所有。请勿转载和采集!