Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::hash<Guid> implementation for use with std containers #4

Closed
antiprosynthesis opened this issue Dec 2, 2015 · 4 comments
Closed

Comments

@antiprosynthesis
Copy link

Here's a little piece of code that can be added to be able to use Guid as key for containers like std::unordered_map:

namespace std
{
template<>
struct hash<Guid>
{
    size_t operator()(const Guid &guid) const
    {
        stringstream ss;
        ss << guid;
        return hash<string>()(ss.str());
    }
};
}
@fish2000
Copy link
Contributor

Oh wow I just submitted PR #6, with similar implementation (I also expanded stringification, to sidestep the need for the relatively heavyweight std::stringstream invocation). Great minds, yes!

@Justinzobel
Copy link

@fish2000 @antiprosynthesis I'd suggest getting together and forking this as it seems abandoned. If you do please tag me here :)

@eliaskosunen
Copy link
Contributor

@Justinzobel I maintain a fork of this repo that implements this and many other™ features: https://github.com/eliaskosunen/crossguid

@graeme-hill
Copy link
Owner

I just merged it and made a few tweaks to make it compile in android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants