c++ - How can I use boost::thread::id as key to an unordered_map? -


According to

, each code can be considered a boost :: thread :: id unique Is thread and containers such as std :: set and std :: map <(<< is overridden for operator ) Can be used in the> thread: id ).

My problem is that I want to use thread :: id as a key for a boost: Unordered_map , though its The key is that the key is "positive" (i.e. supports hashing for a size_t ). Since all the implementation details for the thread :: id are hidden, I do not think I can use anything.

So my question is - It is possible to use the thread :: id one unordered_map

You can use the ability of streaming:

  struct hashrer {size_t operator (const boost :: thread :: id and id) { Std :: ostringstream os; OS & lt; & Lt; Id; Return hash (os.str ()); }};  

A bit of the class, so that others can see what's possible:

  class thread :: id {public: id (); Bull Operator == (Constant ID & amp; y) Const .; Bull Operator! = (Constant ID & amp; y) Constance; The Bull Operator & lt; (Constant ID & amp; y) console; BULL operator & gt; (Constant ID & amp; y) console; The Bull Operator & lt; = (Constant ID & amp; y) Constance; BULL operator & gt; = (Constant ID & amp; y) Constance; Template & lt; Square chart, class characterization & gt; Friend std :: basic_ostream & lt; CharT, symptom & gt; & Amp; Operator & lt; & Lt; (Std :: basic_ostream & lt; charT, symptom & gt; & amp; os, const id & amp; x); };  

Comments