C++ set keyCompare function for vector -


i'm storing glm::ivec3 keys in set. since type missing keycompare function i've defined in struct. if have 2 numbers a,b write < b; how vector?

i tried following:

struct keycompare {     bool operator()(const glm::ivec3& a, const glm::ivec3& b)const     {         return a.x < b.x && a.y < b.y && a.z < b.z;     } };  typedef set<glm::ivec3, keycompare> chunkset; 

now able insert values, when checking whether value exists returned true without ever inserting key.

do know how comparing done vectors?

thanks in advance!

you can try

return a.x < b.x || (a.x == b.x && a.y < b.y) || (a.x == b.x && a.y == b.y && a.z < b.z); 

the problem initial implementation following vectors seem equal because !(a < b) && !(b < a) held implementation:

(3, 7, 12), (4, 6, 12) 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -