hash/{std,tuple}: operators should be const

This commit is contained in:
Danny Robson 2023-07-25 10:00:30 +10:00
parent ef309fd4de
commit e02a4e2594
2 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@ namespace cruft::hash {
// Useful as a component in more complex hash objects (eg, hash::tuple) // Useful as a component in more complex hash objects (eg, hash::tuple)
struct std { struct std {
template <typename ValueT> template <typename ValueT>
auto operator () (ValueT &&val) auto operator () (ValueT &&val) const
{ {
using inner_t = ::std::remove_cvref_t<ValueT>; using inner_t = ::std::remove_cvref_t<ValueT>;
return ::std::hash<inner_t> {} (::std::forward<ValueT> (val)); return ::std::hash<inner_t> {} (::std::forward<ValueT> (val));

View File

@ -19,7 +19,7 @@ namespace cruft::hash {
public: public:
template <typename ...ValueT> template <typename ...ValueT>
auto auto
operator() (std::tuple<ValueT...> const &val) operator() (std::tuple<ValueT...> const &val) const
{ {
return compute (val, std::make_index_sequence<sizeof... (ValueT)> {}); return compute (val, std::make_index_sequence<sizeof... (ValueT)> {});
} }
@ -27,7 +27,7 @@ namespace cruft::hash {
private: private:
template <typename ...ValueT, std::size_t ...IndexV> template <typename ...ValueT, std::size_t ...IndexV>
auto auto
compute (std::tuple<ValueT...> const &val, std::index_sequence<IndexV...>) compute (std::tuple<ValueT...> const &val, std::index_sequence<IndexV...>) const
{ {
return MixT {} ( return MixT {} (
ElementT {} (std::get<IndexV> (val))... ElementT {} (std::get<IndexV> (val))...