home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,860 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: default hash performance of unordere   
   14 Feb 13 11:44:47   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2013-02-14 01:14, TS wrote:   
   > I just noticed that C++0x includes unordered_map/set based on hash table.   
   > They allow users to specify their own hash and compare functions. However,   
   > it seems that they also include some default implementations of those   
   > functions, as compilers do not complain even if I don't provide them.   
   >   
   > My questions are   
   > 1. How are the performance of the default hash functions?   
      
   How do you define "performance"? The standard is silent on this, so this   
   is not specified.   
      
   > 2. If I use a class defined by myself as a key, how does the default   
   > hash function know how to hash my type?   
      
   It cannot know, unless you specialize the std::hash template for that   
   class type. If you don't provide it, the instantiation of   
   std::hash will be ill-formed.   
      
   > 3. Have the default functions been optimized for certain built-in types?   
      
   How do you define "optimized"? The standard is silent on this, so this   
   is not specified.   
      
   Your questions seem to indicate that you have a rather specific   
   understanding on what you would consider as an appropriate hash   
   function. If this is so, you should provide your own hasher.   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca