Files
cppdraft_translate/cppdraft/optional/hash.md
2025-10-25 03:02:53 +03:00

26 lines
856 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[optional.hash]
# 22 General utilities library [[utilities]](./#utilities)
## 22.5 Optional objects [[optional]](optional#hash)
### 22.5.11 Hash support [optional.hash]
[🔗](#lib:hash,optional)
`template<class T> struct hash<optional<T>>;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5517)
The specialization hash<optional<T>> is enabled ([[unord.hash]](unord.hash "22.10.19Class template hash"))
if and only if hash<remove_const_t<T>> is enabled[.](#1.sentence-1)
When enabled, for an object o of type optional<T>,
if o.has_value() == true, then hash<optional<T>>()(o) evaluates to the same value as hash<remove_const_t<T>>()(*o);
otherwise it evaluates to an unspecified value[.](#1.sentence-2)
The member functions are not guaranteed to be noexcept[.](#1.sentence-3)