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

Define std::hash<boost::variant<Ts...>> for compat with std::variant #49

Closed
alex-weej opened this issue Jul 6, 2018 · 5 comments

Comments

@alex-weej
Copy link

commented Jul 6, 2018

As in boostorg/optional#55 for optional, it would be useful to provide this so we can use C++11 unordered_map with boost::variant and have a similar experience to C++17 std::variant.

@akrzemi1

@apolukhin apolukhin closed this in d972192 Aug 12, 2018
apolukhin added a commit that referenced this issue Aug 12, 2018
@apolukhin apolukhin reopened this Aug 12, 2018
@apolukhin

This comment has been minimized.

Copy link
Member

commented Aug 12, 2018

This is a tempting idea however it has many complications:

  • libc++ defines hash in namespace std::__1:: rather than in namespace std::
  • VC defined class hash, rather than struct hash.
  • ???

@akrzemi1 have you dealt with those issues? Probably we need a common solution here (some macro in Boost.Config to specialize std::hash?)

@akrzemi1

This comment has been minimized.

Copy link
Member

commented Aug 17, 2018

No. Did not address it yet in boost::optional. However, in this implementation of Optional: https://github.com/akrzemi1/Optional/ I have simply added a specialization of std::hash and never heard any complaints about it. Maybe nobody uses it. Or maybe the problems you describe apply only to pre-c++11 compilers?

@apolukhin

This comment has been minimized.

Copy link
Member

commented Aug 28, 2018

Probably all my problems are because of the forward declaration of std::hash. I'll try without is soon.

apolukhin added a commit that referenced this issue Apr 1, 2019
@apolukhin apolukhin removed the question label Apr 2, 2019
@apolukhin

This comment has been minimized.

Copy link
Member

commented Apr 2, 2019

Looks like 31dcc43 does the job. I'll merge it after the 1.70 release

apolukhin added a commit that referenced this issue Apr 12, 2019
Add std::hash specialization for variant (refs #49)
@apolukhin

This comment has been minimized.

Copy link
Member

commented Apr 12, 2019

Fixed in #65

@apolukhin apolukhin closed this Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.