xtd 0.2.0
Loading...
Searching...
No Matches
__hasher.h
Go to the documentation of this file.
1
4
5#pragma once
7#if !defined(__XTD_CORE_INTERNAL__)
8#error "Do not include this file: Internal use only"
9#endif
11
12#include "../object"
13#include <functional>
14#include <type_traits>
15
17template<typename key_t, typename bool_t>
18struct __object_hasher__ {};
19
20template<typename key_t>
21struct __object_hasher__<key_t, std::true_type> {
22 size_t operator()(const key_t& key) const {return static_cast<const xtd::object&>(key).get_hash_code();}
23};
24
25template<typename key_t>
26struct __object_hasher__<key_t, std::false_type> {
27 size_t operator()(const key_t& key) const {return std::hash<key_t> {}(key);}
28};
29
30template<typename key_t, typename bool_t>
31struct __polymorphic_hasher__ {};
32
33template<typename key_t>
34struct __polymorphic_hasher__<key_t, std::true_type> {
35 size_t operator()(const key_t& key) const {return __object_hasher__<key_t, typename std::is_base_of<xtd::object, key_t>::type> {}(key);}
36};
37
38template<typename key_t>
39struct __polymorphic_hasher__<key_t, std::false_type> {
40 size_t operator()(const key_t& key) const {return std::hash<key_t> {}(key);}
41};
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42