VCCC  2024.05
VisualCamp Common C++ library
hash.h
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2021/05/24.
3 # */
4 #
5 # ifndef VCCC_OPTIONAL_HASH_H_
6 # define VCCC_OPTIONAL_HASH_H_
7 #
8 # include <cstddef>
9 #
10 # include <functional>
11 # include <type_traits>
12 #
15 
16 namespace std {
17 
20 
25 template<typename T>
26 struct hash<vccc::optional<T>> : vccc::internal::optional::hash_constructible<std::remove_const_t<T>> {
28  using result_type = std::size_t;
29 
31  return key.has_value() ? ::std::hash<std::remove_const_t<T>>()(*key) : 0;
32  }
33 };
34 
36 
37 } // namespace std
38 
39 # endif // VCCC_OPTIONAL_HASH_H_
a wrapper that may or may not hold an object
Definition: optional.h:46
Definition: matrix.hpp:495
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 0 > key
Definition: key_value.hpp:33
std::size_t result_type
Definition: hash.h:28
result_type operator()(const argument_type &key) const
Definition: hash.h:30