Skip to content

Specialization of struct std::hash in different namespace  #626

Open
@ggahan

Description

@ggahan

Attempt at specialization of std::hash outside of proper namespace error encountered with examples.

Example being run: https://github.com/zeromq/cppzmq/blob/master/examples/pubsub_multithread_inproc.cpp

CENTOS 7
gcc 4.8.5

In file included from /home/grigori/Desktop/zeromq_test/main.cpp:7:0:
/home/grigori/Desktop/zeromq_test/zmq_addon.hpp:88:25: error: specialization of ‘template struct std::hash’ in different namespace [-fpermissive]
template <> struct std::hashzmq::poller_ref_t

Recommended fix:
enclose this template in namespace std as:

namespace std
{
  template <> struct hash<zmq::poller_ref_t>
  {
    size_t operator()(const zmq::poller_ref_t& ref) const ZMQ_NOTHROW
    {
      return ref.hash();
    }
  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions