diff --git a/doc/store.rst b/doc/store.rst index 07df997c..d4ceedb4 100644 --- a/doc/store.rst +++ b/doc/store.rst @@ -19,6 +19,6 @@ with_deps store ----- -.. doxygenstruct:: lager::store +.. doxygenclass:: lager::store :members: :undoc-members: diff --git a/lager/extra/derive/hash.hpp b/lager/extra/derive/hash.hpp index d7ad0649..74613d92 100644 --- a/lager/extra/derive/hash.hpp +++ b/lager/extra/derive/hash.hpp @@ -19,8 +19,11 @@ #include +// use formula from boost::hash_combine as in: +// https://www.boost.org/doc/libs/1_55_0/doc/html/hash/reference.html#boost.hash_combine #define LAGER_DERIVE_IMPL_HASH_ITER__(r__, data__, elem__) \ - ::boost::hash_combine(seed, x.elem__); + seed ^= std::hash{}(x.elem__) + 0x9e3779b9 + \ + (seed << 6) + (seed >> 2); #define LAGER_DERIVE_IMPL_HASH(r__, ns__, name__, members__) \ namespace std { \ @@ -46,7 +49,7 @@ std::size_t operator()(const ns__::BOOST_PP_REMOVE_PARENS(name__) & \ x) const \ { \ - auto seed = std::size_t{}; \ + auto seed = typeid(x).hash_code(); \ BOOST_PP_SEQ_FOR_EACH_R( \ r__, LAGER_DERIVE_IMPL_HASH_ITER__, _, members__) \ return seed; \ diff --git a/test/extra/derive.cpp b/test/extra/derive.cpp index ba09933f..3c2caa51 100644 --- a/test/extra/derive.cpp +++ b/test/extra/derive.cpp @@ -89,6 +89,23 @@ TEST_CASE("basic") check_hash(); } +namespace ns { +struct derived2 +{ + derived a; + float b; +}; +} // namespace ns +LAGER_DERIVE((EQ, HANA, CEREAL, HASH), ns, derived2, a, b); + +TEST_CASE("basic-2") +{ + check_eq(); + // check_hana(); + check_cereal(); + check_hash(); +} + namespace ns { struct empty_t {};