How to map a bool to a 3d point struct with std::map?

后端 未结 6 787
情话喂你
情话喂你 2020-12-10 06:21

How do I use the following struct:

struct point 
{
    int x;
    int y;
    int z;
};

as a key for std::map

6条回答
  •  时光取名叫无心
    2020-12-10 06:54

    if they're supposed to be ordered in a certain way, you'll want to specify that exact way (for example by euclidean distance from 0/0/0). If all you want is to distinguish different points, you could do something like

    x == x2 ? (y == y2 ?  (z < z2) : y < y2) : x < x2 
    

提交回复
热议问题