1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
 * @file hashed_string.h
 * @author Benjamin Navarro
 * @brief include file for c++11 hashed string implementation
 * @date 2022-06-10
 * @ingroup hashed-string
 *
 */
#pragma once

#include <pid/cxx11/detail/hashed_string.h>

#include <string>

namespace pid {

//! \brief Hash function for std::basic_string<T> (a.k.a std::string /
//! std::wstring)
//!
//! In C++20 mode, this function can be used on constexpr contexts
//!
//! \tparam CharT Character type, automatically deduced
//! \param str The string to hash
//! \return constexpr uint64_t The resulting hash value
template <typename CharT = char>
inline constexpr std::uint64_t
hashed_string(std::basic_string<CharT> str) noexcept {
    return detail::hashed_string(str);
}

//! \deprecated use hashed_string()
template <typename CharT = char>
[[deprecated("use hashed_string() instead")]] inline constexpr std::uint64_t
hashedString( // NOLINT(readability-identifier-naming)
    std::basic_string<CharT> str) noexcept {
    return hashed_string(str);
}

//! \brief Hash function for character arrays
//!
//! \tparam CharT Character type, automatically deduced
//! \param str The string to hash
//! \return constexpr uint64_t The resulting hash value
template <typename CharT = char>
inline constexpr std::uint64_t hashed_string(const CharT* str) noexcept {
    return detail::hashed_string(str);
}

//! \deprecated use hashed_string()
template <typename CharT = char>
[[deprecated("use hashed_string() instead")]] inline constexpr std::uint64_t
hashedString( // NOLINT(readability-identifier-naming)
    const CharT* str) noexcept {
    return hashed_string(str);
}

} // namespace pid