S
Steve555
Hi,
In a function that erases part of a string, the compiler sometimes
gives this error:
terminate called after throwing an instance of 'std:ut_of_range'
what(): basic_string::erase
I can guess, then, that I'm erasing outside the strings length, but I
can not find the bug:
for(long i=0; i<str.length()-1; i++)
{
if( str == '[' && str[i+1] == ']' )
str.erase(i, 2);
}
Maybe someone can see the problem in this case, but I'm also
interested in generally learning how to use these exceptions.
How do I use 'out_of_range' and 'what' in my source code so I can put
a breakpoint in to the debugger when this error occurs?
Thanks
Steve
In a function that erases part of a string, the compiler sometimes
gives this error:
terminate called after throwing an instance of 'std:ut_of_range'
what(): basic_string::erase
I can guess, then, that I'm erasing outside the strings length, but I
can not find the bug:
for(long i=0; i<str.length()-1; i++)
{
if( str == '[' && str[i+1] == ']' )
str.erase(i, 2);
}
Maybe someone can see the problem in this case, but I'm also
interested in generally learning how to use these exceptions.
How do I use 'out_of_range' and 'what' in my source code so I can put
a breakpoint in to the debugger when this error occurs?
Thanks
Steve