Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6840595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:51:47+00:00 2026-05-26T23:51:47+00:00

Is this an appropriate way to provide unique keys in a map? In other

  • 0

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;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:51:48+00:00Added an answer on May 26, 2026 at 11:51 pm

    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

    struct Uuid {
      uuid_t uuid;
      Uuid(const Uuid &other) { uuid_copy(uuid, other.uuid); }
      Uuid(const uuid_t other_uuid) { uuid_copy(uuid, other_uuid); }
      void generateInplace() { uuid_generate(uuid); }
      static Uuid generate() { Uuid wrapped; uuid_generate(wrapped.uuid); return wrapped; }
      bool operator<(const Uuid &other) { return uuid_compare(uuid, other.uuid) < 0; }
      bool operator==(const Uuid &other) { return uuid_compare(uuid, other.uuid) == 0; }
      // ...
    };
    

    That should hide from you the fact that uuid_t isn’t structure but pointer to array (i.e. typedef unsigned char uuid_t[16]).

    Note: there is boost version of uuid library

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure whether or not this is the appropriate way of doing this,
I'm not sure this question is appropriate here but I hope I could get
This code lets me display/hide a custom message msg_one msg_two msg_three when the appropriate
I call this a flash meeting, but maybe there is another more appropriate name.
I have a class defined like this, with the appropriate getter and setter methods...
Sorry, if this is a duplicate. Please point me to the appropriate question if
First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried
This is an odd problem, so I have to provide a bit of background.
Ok, I asked this question before, but deleted it as the way I went
I need to provide a way of users uploading multiple files (can be 10MB

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.