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 794447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:18:52+00:00 2026-05-14T22:18:52+00:00

According to the documentation , a boost::thread::id can be considered unique for each running

  • 0

According to the documentation, a boost::thread::id can be considered unique for each running thread and can be used in containers such as std::set and std::map (because the < operator is overridden for thread::id).

My problem is that I’d like to use thread::id as a key to an boost::unordered_map, however it requires that the key is “hashable” (ie. supports hashing to a size_t). Since all implementation detail for thread::id is hidden I don’t think have anything I can use.

So my question is – is it possible to use thread::id as a key to an unordered_map?

  • 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-14T22:18:52+00:00Added an answer on May 14, 2026 at 10:18 pm

    You can use the streaming ability:

    struct Hasher
    {
      size_t operator()(const boost::thread::id& id)
      {
        std::ostringstream os; os << id; return hash(os.str());
      }
    };
    

    Little excerpt of the class, so that others may see what’s possible:

    class thread::id
    {
    public:
        id();
    
        bool operator==(const id& y) const;
        bool operator!=(const id& y) const;
        bool operator<(const id& y) const;
        bool operator>(const id& y) const;
        bool operator<=(const id& y) const;
        bool operator>=(const id& y) const;
    
        template<class charT, class traits>
        friend std::basic_ostream<charT, traits>& 
        operator<<(std::basic_ostream<charT, traits>& os, const id& x);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the Boost Documentation , having multiple threads call io_service::run() sets up a
According to Boost documentation boost::mutex and boost::timed_mutex are supposed to be different. The first
Can anyone discern what I'm doing wrong here? According to the documentation in 1.47
according the documentation borderThickness is an applicable style, but when I try to set
According to ADC documentation: You can access Open Firmware this by holding down Command-Option-O-F
There's setDoOutput() in URLConnection . According to documentation I should Set the DoOutput flag
according documentation: On success, the function returns the converted integral number as a long
According to Hibernate documentation : After observing that arrays cannot be lazy , you
According to Apple documentation and other documentation I have read about on disk encryption
According to the documentation for -[UIView setNeedsLayout] : Because this method does not force

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.