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

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

Open
grigori-gahan opened this issue Jan 26, 2024 · 0 comments
Open

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

grigori-gahan opened this issue Jan 26, 2024 · 0 comments

Comments

@grigori-gahan
Copy link

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();
    }
  };
}
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

1 participant