Error: std :: out_of_range

1

I'm having this problem, the program compiles and links, but at the time of executing I throw this bug, if someone could give me a hand.

  

~ / Projects / Queue using vector # ./main terminate called   after throwing an instance of 'std :: out_of_range' what ():   vector :: _ M_range_check: __n (which is 18446744073709551615) > =   this-> size () (which is 20) Aborted

    
asked by Emanuel Clur 09.07.2018 в 20:12
source

1 answer

1

The error is clear and concise, you may not understand it because it is in English, let me translate it:

  

~ / Projects / Queue using vector # ./main was called to terminate after launching an instance of 'std :: out_of_range'

The std::terminate function is automatically called when an exception is thrown ( thrown ) but it is not collected ( catch ).

The exception thrown to you is std::out_of_range that would be translated "Out of range" , this function is launched (among other reasons) when trying to access a memory area presumably handled by a container without the requested memory area belonging to said container.

That is exactly what happened to you, the error indicates that you are using std::vector and you have surely called the function std::vector::at which can throw the mentioned exception. The error tells you that you have accessed the position eighteen trillion four hundred forty-six thousand seven hundred forty-four trillion seventy-three thousand seven hundred nine million five hundred fifty-one thousand six hundred quincimes, which is the position 2 64 .

I bet you have passed a negative number to the function std::vector::at and as the parameter is an unsigned integer type (usually std::size_t ) has overflowed.

    
answered by 09.07.2018 / 21:26
source