[Solved] libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: vector Abort trap: 6. any help would be awesome, thank you


Suppose that v is a vector, only elements v[0] to v[v.size() - 1] are available and v[v.size()] is out-of-range.

Therefore,

for(int i=0;i<=weights.size();i++)

and

for(int it =0;it<=values.size();it++)

should be

for(int i=0;i<weights.size();i++)

and

for(int it =0;it<values.size();it++)

(use < instead of <=)

4

solved libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: vector Abort trap: 6. any help would be awesome, thank you