RPNX::QueryGraph
Typed, memoized, concurrent query evaluation for C++23
Loading...
Searching...
No Matches
hasher.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Ryan P. Nicholl <rnicholl@protonmail.com>
2
3#ifndef RPNXQUERYGRAPH_HASHER_HPP
4#define RPNXQUERYGRAPH_HASHER_HPP
5
10
11#include "rpnx/serialization4.hpp"
12
13#include <functional>
14#include <type_traits>
15#include <typeindex>
16
17namespace rpnx::querygraph
18{
32 template < typename T >
33 struct hasher
34 {
40 auto operator()(T const& value) const -> std::size_t
41 {
42 if constexpr (std::is_same_v< T, std::type_index >)
43 {
44 return std::hash< std::type_index >{}(value);
45 }
46 else
47 {
48 return rpnx::serial4::hash{}(value);
49 }
50 }
51 };
52} // namespace rpnx::querygraph
53
54#endif // RPNXQUERYGRAPH_HASHER_HPP
Hash a value for use as a QueryGraph memoization key.
Definition hasher.hpp:34
auto operator()(T const &value) const -> std::size_t
Compute the hash of a query input.
Definition hasher.hpp:40