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

BOOST_PFR_FUNCTIONS_FOR doesn't nest #89

Open
u3shit opened this issue Jul 31, 2021 · 0 comments
Open

BOOST_PFR_FUNCTIONS_FOR doesn't nest #89

u3shit opened this issue Jul 31, 2021 · 0 comments

Comments

@u3shit
Copy link

u3shit commented Jul 31, 2021

I don't know if this is a bug or feature, but BOOST_PFR_FUNCTIONS_FOR requires structure members to have an std::hash specialization, but it doesn't itself provide one, so the following example fails to compile:

#include <boost/pfr/functions_for.hpp>

struct A { int a; };
BOOST_PFR_FUNCTIONS_FOR(A);
// namespace std { template<> struct hash<A> { size_t operator()(A); }; }

struct B { A a; };
BOOST_PFR_FUNCTIONS_FOR(B);

Godbolt

Uncommenting the hash specialization will make this code compile, but it's bothersome to do this for every type that just needs some comparison and print operations. Would it be possible to have a BOOST_PFR_FUNCTIONS_FOR version that doesn't try to generate a hash function? (Especially that it generates a hash_value function that is only compatible with boost containers, not an std::hash specialization that is a more compatible solution with C++11 or later.) Or at least make hash_fields compatible with hash_value?

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