From ebd2f4120dc1941c5947deeb7e995baef359fc0f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 3 Nov 2024 17:10:23 +0200 Subject: [PATCH] Move is_contiguously_hashable check into hash_append --- include/boost/hash2/hash_append.hpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/include/boost/hash2/hash_append.hpp b/include/boost/hash2/hash_append.hpp index 3eddb89..d6d1daf 100644 --- a/include/boost/hash2/hash_append.hpp +++ b/include/boost/hash2/hash_append.hpp @@ -211,18 +211,6 @@ template hash2::hash_append( h, f, reinterpret_cast( v ) ); } -// contiguously hashable, non-scalar - -template - BOOST_CXX14_CONSTEXPR - typename std::enable_if< - is_contiguously_hashable::value && !std::is_scalar::value, - void>::type - do_hash_append( Hash& h, Flavor const& /*f*/, T const& v ) -{ - h.update( &v, sizeof(T) ); -} - // floating point template @@ -403,9 +391,17 @@ template // hash_append -template BOOST_CXX14_CONSTEXPR void hash_append( Hash& h, Flavor const& f, T const& v ) +template +BOOST_CXX14_CONSTEXPR void hash_append( Hash& h, Flavor const& f, T const& v ) { - do_hash_append( h, f, v ); + if( !detail::is_constant_evaluated() && is_contiguously_hashable::value ) + { + h.update( &v, sizeof(T) ); + } + else + { + do_hash_append( h, f, v ); + } } } // namespace hash2