Boost logo

Boost Users :

Subject: Re: [Boost-users] unordered_map: user object as key
From: Daniel James (dnljms_at_[hidden])
Date: 2010-02-27 14:42:26


On 27 February 2010 19:37, André Santee <andre.santee_at_[hidden]> wrote:
> Thanks,
> I solved my problem by doing this:
>
> namespace boost
> {
>     std::size_t hash_value(const GS_VECTOR2 &v2)
>     {
>         return ((std::size_t)v2.y*COLUMNS)+(std::size_t)v2.x;
>     }
> };
>
> Is it also ok?

Yes, but unless you're using a really old compiler that doesn't
support argument dependent lookup (ADL), you should put the function
in the same namespace as your vector. You can read about ADL at:

http://en.wikipedia.org/wiki/Argument_dependent_name_lookup

Daniel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net