Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Argghh.. hash_map problems again

This topic is 6031 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Some time ago i had a problem with the hashing method used by hash_map on std::string''s, but someone here was nice enough to suggest defining this:
size_t std::hash_compare<std::string>::operator ()(const std::string& val) const
	size_t keyVal = 0;	
	for(size_t i = 0, l = val.size(); i < l; ++i)	
		keyVal += val[i];
	ldiv_t div = ldiv((long)keyVal, 127773);	
	div.rem = 16807 * div.rem - 2836 * div.quot;	
	if(div.rem < 0)	
		div.rem += 2147483647;	
	return div.rem;
This worked just fine. But suddenly, almost out of the blue im getting this error regarding the above:
d:\test\test\tets\SettingsParser.cpp(12): error C2511: ''size_t std::hash_compare<_Kty,_Pr>::operator ()(const std::string &) const'' : overloaded member function not found in ''std::hash_compare<_Kty,_Pr>''
Should i on the other hand just remove the hash method defined above, i get these errors:
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xhash(217): error C2064: term does not evaluate to a function
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xhash(217): error C2660: ''std::hash_compare,class std::allocator >,struct std::less,class std::allocator > > >::operator`()'''' : function does not take 1 parameters
This error comes even just from this code(removed the rest of the code to narrow down the cause of this):
#include <string>
#include <hash_map>
using namespace std;

static hash_map<string, string> settings;

void changeSetting(string setting, string value)
	settings[setting] = value;
I really dont understand this, i even tried going back to an older build of my project which i *KNOW* worked, and i can link it and run it, but if i *rebuild* it i get these errors.... ARGGHHH.... To make things even worse ive caught a terrible cold, so now im sitting here red-eyed sniffling over a project that wont compile ;(

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!