Ell 05/03/2013, a las 18:15, "Akim Demaille"
Hi all,
My parser is building string_t = flyweightstd::string for identifiers, and it works very well. Now, I would like to make an unordered_map
, 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.
This is absolutely correct, and in fact the optimum way to hash flyweights.
In particular, I don't understand why their is no standard hash function defined for flyweights.
No particular reason other than that it is not customary to provide this definition in advance for most non-primitive types provided by Boost. Joaquín M López Muñoz Telefónica Digital ________________________________ Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo. This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at: http://www.tid.es/ES/PAGINAS/disclaimer.aspx