1#ifndef LIBSBX_UTILITY_HASHED_STRING_HPP_
2#define LIBSBX_UTILITY_HASHED_STRING_HPP_
10namespace sbx::utility {
12template<
character Char,
typename Hash = std::u
int64_t,
typename HashFunction = fnv1a_hash<Char, Hash>>
17 using char_type = HashFunction::char_type;
18 using size_type = HashFunction::size_type;
19 using hash_type = HashFunction::hash_type;
26 : _string{string, length},
27 _hash{HashFunction{}(_string)} {}
29 template<std::
size_t Size>
31 : _string{string, Size - 1},
32 _hash{HashFunction{}(_string)} {}
36 _hash{HashFunction{}(_string)} {}
49 return _hash == other._hash;
52 auto data()
const noexcept ->
const char_type* {
53 return _string.data();
56 auto size()
const noexcept -> size_type {
57 return _string.size();
60 auto hash()
const noexcept -> hash_type {
64 auto c_str()
const noexcept ->
const char_type* {
65 return _string.c_str();
68 operator hash_type()
const noexcept {
74 std::basic_string<char_type> _string{};
85inline auto operator""_hs(
const char*
string,
const std::size_t length) ->
hashed_string {
89inline auto operator""_hs(
const wchar_t*
string,
const std::size_t length) -> hashed_wstring {
90 return hashed_wstring{string, length};
97template<sbx::utility::
character Char,
typename Hash,
typename HashFunction>
98struct std::hash<sbx::utility::basic_hashed_string<Char, Hash, HashFunction>> {
100 return string.hash();
Definition: hashed_string.hpp:13