Boost logo

Boost Users :

Subject: [Boost-users] Flyweights: compute a hash from them
From: Akim Demaille (akim_at_[hidden])
Date: 2013-03-05 12:13:26


Hi all,

My parser is building string_t = flyweight<std::string> for identifiers,
and it works very well. Now, I would like to make an unordered_map
<string_t, foo_t>, but I have to define a hash function for string_t.
I can do it but since the whole point of flyweight is to make unique
instances, it would be a pity to hash the value. So I hash the address
of the result of get().

Is this ok? So far everything is fine, but I might have missed something.
In particular, I don't understand why their is no standard hash function
defined for flyweights.

Thanks in advance!


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net