https://github.com/boostorg/container_hash/blob/develop/include/boost/container_hash/hash.hpp
Since most part of internal calculations are based on integer arithmetic and bitwise operations, I believe those three functions and all their variants can be marked constexpr today. Can someone please enlighten me, why the standard std::hash<T>::operator() and proposed std::hash_combine() in P0814R2 is not constexpr? (backward-compatibility, or other reasons?)
If we are to provide constexpr-ness, there are two cases of implementations:
- When user is using standard later or equal to C++20
- In this case, non-constexpr intrinsic like
_rotl (defined for BOOST_FUNCTIONAL_HASH_ROTL32) can be replaced with std::rotl
- When user is using C++14 to C++17 and one prefers constexpr
- The library can fallback to bitwise implementation (which is always
constexpr)
- Currently Boost.ContainerHash provides no option for this case. I think new macro like
BOOST_FUNCTIONAL_HASH_USE_CONSTEXPR is needed.
refs: cplusplus/papers#253
https://github.com/boostorg/container_hash/blob/develop/include/boost/container_hash/hash.hpp
Since most part of internal calculations are based on integer arithmetic and bitwise operations, I believe those three functions and all their variants can be marked
constexprtoday. Can someone please enlighten me, why the standardstd::hash<T>::operator()and proposedstd::hash_combine()in P0814R2 is notconstexpr? (backward-compatibility, or other reasons?)If we are to provide constexpr-ness, there are two cases of implementations:
_rotl(defined forBOOST_FUNCTIONAL_HASH_ROTL32) can be replaced withstd::rotlconstexpr)BOOST_FUNCTIONAL_HASH_USE_CONSTEXPRis needed.refs: cplusplus/papers#253