Skip to content

Implement std::hash for beman::optional#69

Merged
steve-downey merged 3 commits intobemanproject:mainfrom
steve-downey:hash
Oct 16, 2024
Merged

Implement std::hash for beman::optional#69
steve-downey merged 3 commits intobemanproject:mainfrom
steve-downey:hash

Conversation

@steve-downey
Copy link
Member

A std::hash implementation for optional, the hash of the underlying value, or 0 for disengaged.

A std::hash implementation for optional, the hash of the underlying value, or 0
for disengaged.
struct hash<beman::optional26::optional<T>> {
static_assert(!is_reference_v<T>, "hash is not enabled for reference types");
size_t operator()(const beman::optional26::optional<T>& o) const
noexcept(noexcept(hash<remove_const_t<T>>{}(*o))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need nested noexcept here. For example, is noexcept(true) different from noexcept(noexcept(true)) ?

Copy link
Member

@neatudarius neatudarius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 with minor suggestions

@neatudarius neatudarius self-assigned this Oct 7, 2024
@steve-downey steve-downey merged commit 863a89c into bemanproject:main Oct 16, 2024
@steve-downey steve-downey deleted the hash branch May 30, 2025 22:32
@steve-downey steve-downey restored the hash branch May 31, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants