Skip to content

Commit

Permalink
Merge pull request arximboldi#152 from arximboldi/some-fixes
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
arximboldi authored Jun 21, 2022
2 parents 8fe5269 + b1783a6 commit 56125da
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/store.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ with_deps
store
-----

.. doxygenstruct:: lager::store
.. doxygenclass:: lager::store
:members:
:undoc-members:
7 changes: 5 additions & 2 deletions lager/extra/derive/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@

#include <functional>

// 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<decltype(x.elem__)>{}(x.elem__) + 0x9e3779b9 + \
(seed << 6) + (seed >> 2);

#define LAGER_DERIVE_IMPL_HASH(r__, ns__, name__, members__) \
namespace std { \
Expand All @@ -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; \
Expand Down
17 changes: 17 additions & 0 deletions test/extra/derive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ TEST_CASE("basic")
check_hash<ns::derived>();
}

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<ns::derived2>();
// check_hana<ns::derived2>();
check_cereal<ns::derived2>();
check_hash<ns::derived2>();
}

namespace ns {
struct empty_t
{};
Expand Down

0 comments on commit 56125da

Please sign in to comment.