diff --git a/include/simstr/sstring.h b/include/simstr/sstring.h index 5ad41e2..023ef67 100644 --- a/include/simstr/sstring.h +++ b/include/simstr/sstring.h @@ -5723,8 +5723,7 @@ struct strhash { // hash functor for basic_string size_t operator()(simple_str _Keyval) const { return fnv_hash(_Keyval.symbols(), _Keyval.length()); } - template - size_t operator()(const StoreType& _Keyval) const { + size_t operator()(const StoreType>& _Keyval) const { return _Keyval.hash; } }; @@ -5742,8 +5741,7 @@ struct strhashia { size_t operator()(simple_str _Keyval) const { return fnv_hash_ia(_Keyval.symbols(), _Keyval.length()); } - template - size_t operator()(const StoreType& _Keyval) const { + size_t operator()(const StoreType>& _Keyval) const { return _Keyval.hash; } }; @@ -5761,8 +5759,7 @@ struct strhashiu { size_t operator()(simple_str _Keyval) const { return unicode_traits::hashiu(_Keyval.symbols(), _Keyval.length()); } - template - size_t operator()(const StoreType& _Keyval) const { + size_t operator()(const StoreType>& _Keyval) const { return _Keyval.hash; } }; @@ -6112,14 +6109,18 @@ SS_CONSTEVAL simple_str_nt operator""_ss(const u32s* ptr, size_t l) { return simple_str_nt{ptr, l}; } +template using HashKey = StoreType>; +template using HashKeyIA = StoreType>; +template using HashKeyIU = StoreType>; + /*! * @brief Оператор литерал в ключ для hashStrMap с посчитанным в compile time хешем с учётом регистра * @param ptr - указатель на строку * @param l - длина строки * @return StoreType */ -consteval StoreType> operator""_h(const u8s* ptr, size_t l) { - return StoreType>{{ptr, l}, fnv_hash_compile(ptr, l)}; +consteval HashKey operator""_h(const u8s* ptr, size_t l) { + return HashKey{{ptr, l}, fnv_hash_compile(ptr, l)}; } /*! @@ -6128,8 +6129,8 @@ consteval StoreType> operator""_h(const u8s* ptr, size_t l) { * @param l - длина строки * @return StoreType */ -consteval StoreType> operator""_ia(const u8s* ptr, size_t l) { - return StoreType>{{ptr, l}, fnv_hash_ia_compile(ptr, l)}; +consteval HashKeyIA operator""_ia(const u8s* ptr, size_t l) { + return HashKeyIA{{ptr, l}, fnv_hash_ia_compile(ptr, l)}; } /*! @@ -6138,8 +6139,8 @@ consteval StoreType> operator""_ia(const u8s* ptr, size_t l) * @param l - длина строки * @return StoreType */ -inline StoreType> operator""_iu(const u8s* ptr, size_t l) { - return StoreType>{{ptr, l}, strhashiu{}(simple_str{ptr, l})}; +inline HashKeyIU operator""_iu(const u8s* ptr, size_t l) { + return HashKeyIU{{ptr, l}, strhashiu{}(simple_str{ptr, l})}; } /*! @@ -6148,8 +6149,8 @@ inline StoreType> operator""_iu(const u8s* ptr, size_t l) { * @param l - длина строки * @return StoreType */ -consteval StoreType> operator""_h(const u16s* ptr, size_t l) { - return StoreType>{{ptr, l}, fnv_hash_compile(ptr, l)}; +consteval HashKey operator""_h(const u16s* ptr, size_t l) { + return HashKey{{ptr, l}, fnv_hash_compile(ptr, l)}; } /*! @@ -6158,8 +6159,8 @@ consteval StoreType> operator""_h(const u16s* ptr, size_t l) * @param l - длина строки * @return StoreType */ -consteval StoreType> operator""_ia(const u16s* ptr, size_t l) { - return StoreType>{{ptr, l}, fnv_hash_ia_compile(ptr, l)}; +consteval HashKeyIA operator""_ia(const u16s* ptr, size_t l) { + return HashKeyIA{{ptr, l}, fnv_hash_ia_compile(ptr, l)}; } /*! @@ -6168,8 +6169,8 @@ consteval StoreType> operator""_ia(const u16s* ptr, size_t * @param l - длина строки * @return StoreType */ -inline StoreType> operator""_iu(const u16s* ptr, size_t l) { - return StoreType>{{ptr, l}, strhashiu{}(simple_str{ptr, l})}; +inline HashKeyIU operator""_iu(const u16s* ptr, size_t l) { + return HashKeyIU{{ptr, l}, strhashiu{}(simple_str{ptr, l})}; } /*! @@ -6178,8 +6179,8 @@ inline StoreType> operator""_iu(const u16s* ptr, size_t l) * @param l - длина строки * @return StoreType */ -consteval StoreType> operator""_h(const u32s* ptr, size_t l) { - return StoreType>{{ptr, l}, fnv_hash_compile(ptr, l)}; +consteval HashKey operator""_h(const u32s* ptr, size_t l) { + return HashKey{{ptr, l}, fnv_hash_compile(ptr, l)}; } /*! @@ -6188,8 +6189,8 @@ consteval StoreType> operator""_h(const u32s* ptr, size_t l) * @param l - длина строки * @return StoreType */ -consteval StoreType> operator""_ia(const u32s* ptr, size_t l) { - return StoreType>{{ptr, l}, fnv_hash_ia_compile(ptr, l)}; +consteval HashKeyIA operator""_ia(const u32s* ptr, size_t l) { + return HashKeyIA{{ptr, l}, fnv_hash_ia_compile(ptr, l)}; } /*! @@ -6198,10 +6199,39 @@ consteval StoreType> operator""_ia(const u32s* ptr, size_t * @param l - длина строки * @return StoreType */ -inline StoreType> operator""_iu(const u32s* ptr, size_t l) { - return StoreType>{{ptr, l}, strhashiu{}(simple_str{ptr, l})}; +inline HashKeyIU operator""_iu(const u32s* ptr, size_t l) { + return HashKeyIU{{ptr, l}, strhashiu{}(simple_str{ptr, l})}; } +/*! + * @brief Оператор литерал в ключ для hashStrMap с посчитанным в compile time хешем с учётом регистра + * @param ptr - указатель на строку + * @param l - длина строки + * @return StoreType + */ +consteval HashKey operator""_h(const uws* ptr, size_t l) { + return HashKey{{ptr, l}, fnv_hash_compile(ptr, l)}; +} + +/*! + * @brief Оператор литерал в ключ для hashStrMap с посчитанным в compile time хешем без учёта регистра ASCII + * @param ptr - указатель на строку + * @param l - длина строки + * @return StoreType + */ +consteval HashKeyIA operator""_ia(const uws* ptr, size_t l) { + return HashKeyIA{{ptr, l}, fnv_hash_ia_compile(ptr, l)}; +} + +/*! + * @brief Оператор литерал в ключ для hashStrMap с посчитанным в compile time хешем без учёта регистра simple unicode + * @param ptr - указатель на строку + * @param l - длина строки + * @return StoreType + */ +inline HashKeyIU operator""_iu(const uws* ptr, size_t l) { + return HashKeyIU{{ptr, l}, strhashiu{}(simple_str{ptr, l})}; +} } // namespace literals /*!