Archive 19/01/2023.

[Solved] Vector::Remove() can’t compile

George

Hi,

I have an error using the Vector::Remove(object)

All other functions (add erase) works accept this. I’m using version on GIT download 15 or 16 days ago.

void EventList::Remove(const VEvent &event) { lstEvents.Remove(event); }

Error code in visual studio 2015:

Severity Code Description Project File Line
Error C2676 binary ‘!=’: ‘VEvent’ does not define this operator or a conversion to a type acceptable to the predefined operator NVuDu e:\projectcodes\urho3d-master\buildvs2015\include\urho3d\container\vector.h 350

Iterator Find(const T& value) { Iterator it = Begin(); while (it != End() && *it != value) //Error at this line ++it; return it; }

cadaver

Remove() does a value search, so your type needs equality/inequality operators.

Note that this is not good for performance, so if you already know where in your vector the value is found then using Erase() with an iterator or index is faster.

George

Thanks that works fine.

Can you check the below uniform random function. It seems to also generate -ve value.

Random(0, 100000);

Regards
George

cadaver

Yes, there were integer overflows with large ranges. Should be fixed in master.