diff --git a/include/cppast/cpp_entity_index.hpp b/include/cppast/cpp_entity_index.hpp index 031b50f..8e26a8a 100644 --- a/include/cppast/cpp_entity_index.hpp +++ b/include/cppast/cpp_entity_index.hpp @@ -5,6 +5,7 @@ #ifndef CPPAST_CPP_ENTITY_INDEX_HPP_INCLUDED #define CPPAST_CPP_ENTITY_INDEX_HPP_INCLUDED +#include #include #include #include @@ -23,20 +24,21 @@ class cpp_namespace; /// \exclude namespace detail { - constexpr std::size_t fnv_basis = 14695981039346656037ull; - constexpr std::size_t fnv_prime = 1099511628211ull; + using hash_type = std::uint_least64_t; + constexpr hash_type fnv_basis = 14695981039346656037ull; + constexpr hash_type fnv_prime = 1099511628211ull; // FNV-1a 64 bit hash - constexpr std::size_t id_hash(const char* str, std::size_t hash = fnv_basis) + constexpr hash_type id_hash(const char* str, hash_type hash = fnv_basis) { - return *str ? id_hash(str + 1, (hash ^ std::size_t(*str)) * fnv_prime) : hash; + return *str ? id_hash(str + 1, (hash ^ hash_type(*str)) * fnv_prime) : hash; } } // namespace detail /// A [ts::strong_typedef]() representing the unique id of a [cppast::cpp_entity](). /// /// It is comparable for equality. -struct cpp_entity_id : type_safe::strong_typedef, +struct cpp_entity_id : type_safe::strong_typedef, type_safe::strong_typedef_op::equality_comparison { explicit cpp_entity_id(const std::string& str) : cpp_entity_id(str.c_str()) {} @@ -118,7 +120,7 @@ private: { std::size_t operator()(const cpp_entity_id& id) const noexcept { - return static_cast(id); + return std::size_t(static_cast(id)); } };