Naming conflict when editing std

I have a templated class function<D, R>, and I am trying to make a hash for it like so:

namespace std {
    template<typename D, typename R>
    template<>
    struct hash<function<D, R>>
    {
        // hash related stuff
    };
}

However, function collides with a class inside of std. Can I avoid this without renaming function and without having to create a templated Hash struct?

Answer

You can ensure that the name lookup finds your class by using a fully qualified name instead of an unqualified name. Like this:

struct hash<::some::ns::function<D, R>>

It doesn’t necessarily have to be fully qualified as long as it is unambiguous with any function declared in other namespaces.