OpenKalman
get_descriptor_hash_code.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2025 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
16 #ifndef OPENKALMAN_GET_HASH_CODE_HPP
17 #define OPENKALMAN_GET_HASH_CODE_HPP
18 
20 #include "coordinates/interfaces/coordinate_descriptor_traits.hpp"
22 
24 {
29 #ifdef __cpp_concepts
30  template<descriptor Arg>
31  constexpr std::convertible_to<std::size_t> auto
32 #else
33  template<typename Arg, std::enable_if_t<descriptor<Arg>, int> = 0>
34  constexpr auto
35 #endif
36  get_descriptor_hash_code(const Arg& arg)
37  {
38  if constexpr (values::index<Arg>)
39  {
40  return values::cast_to<std::size_t>(arg);
41  }
42  else
43  {
44  using U = std::decay_t<stdex::unwrap_reference_t<Arg>>;
46  if constexpr (std::is_same_v<U, Arg>) return Traits::hash_code(arg);
47  else return Traits::hash_code(arg.get());
48  }
49  }
50 
51 
52 }
53 
54 
55 #endif
Definition for values::index.
Definition: get_descriptor_dimension.hpp:25
constexpr auto get_descriptor_hash_code(const Arg &arg)
Obtain a unique hash code for an coordinates::descriptor.
Definition: get_descriptor_hash_code.hpp:36
Definition for coordinates::descriptor.
Traits for coordinates::pattern objects.
Definition: coordinate_descriptor_traits.hpp:36