1 #ifndef ENTT_CORE_HASHED_STRING_HPP
2 #define ENTT_CORE_HASHED_STRING_HPP
7 #include "../config/config.h"
27 struct fnv1a_traits<std::uint32_t> {
28 using type = std::uint32_t;
29 static constexpr std::uint32_t offset = 2166136261;
30 static constexpr std::uint32_t prime = 16777619;
35 struct fnv1a_traits<std::uint64_t> {
36 using type = std::uint64_t;
37 static constexpr std::uint64_t offset = 14695981039346656037ull;
38 static constexpr std::uint64_t prime = 1099511628211ull;
62 template<
typename Char>
64 using traits_type = internal::fnv1a_traits<ENTT_ID_TYPE>;
66 struct const_wrapper {
68 constexpr const_wrapper(
const Char *curr) ENTT_NOEXCEPT: str{curr} {}
73 static constexpr ENTT_ID_TYPE helper(
const Char *curr) ENTT_NOEXCEPT {
74 auto value = traits_type::offset;
77 value = (
value ^ static_cast<traits_type::type>(*(curr++))) * traits_type::prime;
104 template<std::
size_t N>
115 return helper(wrapper.str);
125 ENTT_ID_TYPE partial{traits_type::offset};
126 while(size--) { partial = (partial^(str++)[0])*traits_type::prime; }
132 : str{
nullptr}, hash{}
149 template<std::
size_t N>
151 : str{curr}, hash{helper(curr)}
160 : str{wrapper.str}, hash{helper(wrapper.str)}
194 return hash == other.hash;
213 template<
typename Char, std::
size_t N>
215 -> basic_hashed_string<Char>;
225 template<
typename Char>
227 return !(lhs == rhs);
247 constexpr
entt::hashed_string operator"" ENTT_HS_SUFFIX(
const char *str, std::size_t) ENTT_NOEXCEPT {
257 constexpr
entt::hashed_wstring operator"" ENTT_HWS_SUFFIX(
const wchar_t *str, std::size_t) ENTT_NOEXCEPT {