diff --git a/.clang-tidy b/.clang-tidy index 54c2b0183dbbe..107ca7c10dbd2 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -23,7 +23,6 @@ readability-*,\ -bugprone-undefined-memory-manipulation,\ -bugprone-unused-return-value,\ -bugprone-use-after-move,\ --cert-dcl59-cpp,\ -cert-env33-c,\ -cert-err34-c,\ -cert-flp30-c,\ diff --git a/src/tuple_hash.h b/src/tuple_hash.h index 0462f4ad330b4..47ef7a15c72ce 100644 --- a/src/tuple_hash.h +++ b/src/tuple_hash.h @@ -8,8 +8,6 @@ // so that it is picked up by argument-dependent name lookup (ADL). namespace cata { -namespace -{ // Code from boost // Reciprocal of the golden ratio helps spread entropy @@ -23,29 +21,33 @@ inline void hash_combine( std::size_t &seed, const T &v ) seed ^= std::hash()( v ) + 0x9e3779b9 + ( seed << 6 ) + ( seed >> 2 ); } +namespace tuple_hash_detail +{ + // Recursive template code derived from Matthieu M. template < class Tuple, size_t Index = std::tuple_size::value - 1 > -struct HashValueImpl +struct Impl { static void apply( size_t &seed, const Tuple &tuple ) { - HashValueImpl < Tuple, Index - 1 >::apply( seed, tuple ); + Impl < Tuple, Index - 1 >::apply( seed, tuple ); hash_combine( seed, std::get( tuple ) ); } }; template -struct HashValueImpl { +struct Impl { static void apply( size_t &seed, const Tuple &tuple ) { hash_combine( seed, std::get<0>( tuple ) ); } }; -} // namespace + +} // namespace tuple_hash_detail struct tuple_hash { template std::size_t operator()( const std::tuple &tt ) const { size_t seed = 0; - HashValueImpl >::apply( seed, tt ); + tuple_hash_detail::Impl >::apply( seed, tt ); return seed; }