Is this an appropriate way to provide unique keys in a map? In other words, is the key being made from the unique value contained in the uuid, or is it being made from the pointer to the uuid_t struct? A side question, is there a more efficient container, when I don’t care about the ordering by keys inside the container?
#include <uuid/uuid.h>
int main(int argc, char **argv)
{
std::map<uuid_t,int> myMap;
uuid_t id1;
uuid_t id2;
uuid_generate( (unsigned char *)&id1 );
uuid_generate( (unsigned char *)&id2 );
myMap[id1] = 5;
myMap[id2] = 4;
}
I guess the best way of using third-party C-structures is to use them through their friendly functions. So if you wanna use uuid_t in STL, I’d suggest you to create some kind of C++ interface/wrapper to that structure like
That should hide from you the fact that
uuid_tisn’t structure but pointer to array (i.e.typedef unsigned char uuid_t[16]).Note: there is boost version of uuid library