boostorg / boostorg/hana

Support hash of hana::integral_constant with enum types

Open
#439 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.9k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

Hi, first of all, thak you for this great library !
I only use it since today, so I'm maybe missing something :

`hana::integral_constant` can be useful e.g. to map enum values to types, but `hana::detail::hash_integral_helper` lacks a specialization of enum types, even though `hana::integral_constant` is recognized as an `IntegralConstant` (which leads to a less explicit error than "this type is not Hashable").

The fix is simple, I have a working specialization for enum types :

```
template
struct hash_integral_helper::value>::type
> {
template
static constexpr auto apply(X const&) {
using Integral = typename std::conditional>::value,
signed long long, unsigned long long
>::type;
constexpr auto x = static_cast(X::value);
return hana::type_c>;
}
};
```

Contributor guide

Open the contributing guide

Research direction

Start by locating hana::detail::hash_integral_helper and reviewing its existing specializations. Add coverage for enum-valued hana::integral_constant using the behavior described in the issue, then verify that enum types are accepted as Hashable and produce the expected integral hash type.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.