So I have a class containing two strings:
class Foo
{
string s1, s2;
...
and I'd like to add a toHash() member, but I can't find
the built-in string hash function. These don't work:
s1.toHash()
s1.toHash
s1.hash
s1.hash()
hash(s1)
yet strings can clearly be the key in a map
On 08/28/2010 10:25 PM, bearophile wrote:
torhu:
string a = abc;
auto hash = typeid(a).getHash(a);
If higher performance is necessary, you may pre-compute part of that:
void main() {
string a = abc;
auto hash1 = typeid(a).getHash(a);
auto stringHash =(typeid(a).getHash);
() {
enum int NLOOP = 30_000_000;
string s = and I'd like to add a toHash() member, but I can't find the
built-in string hash function.;
{
auto t0 = getUTCtime();
auto stringHash =(typeid(s).getHash);
hash_t tot;
for (int i; i NLOOP; i++)
tot