Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::utils::StringHash Struct Reference

Transparent hash functor for string types. More...

#include <string_hash.hpp>

Public Types

using is_transparent = void
 Enables heterogeneous lookup.
using hash_type = std::hash<std::string_view>

Public Member Functions

size_t operator() (std::string_view str) const noexcept
 Hashes a string-like object.
size_t operator() (const std::string &str) const noexcept
 Hashes a std::string.
size_t operator() (const char *str) const noexcept
 Hashes a C-style string.

Detailed Description

Transparent hash functor for string types.

Enables heterogeneous lookup in unordered containers, allowing lookups with std::string_view without constructing temporary std::string objects. Supports std::string, std::string_view, and const char*.

Definition at line 17 of file string_hash.hpp.

Member Typedef Documentation

◆ hash_type

using helios::utils::StringHash::hash_type = std::hash<std::string_view>

Definition at line 19 of file string_hash.hpp.

◆ is_transparent

Enables heterogeneous lookup.

Definition at line 18 of file string_hash.hpp.

Member Function Documentation

◆ operator()() [1/3]

size_t helios::utils::StringHash::operator() ( const char * str) const
inlinenodiscardnoexcept

Hashes a C-style string.

Parameters
strString to hash
Returns
Hash value

Definition at line 44 of file string_hash.hpp.

◆ operator()() [2/3]

size_t helios::utils::StringHash::operator() ( const std::string & str) const
inlinenodiscardnoexcept

Hashes a std::string.

Parameters
strString to hash
Returns
Hash value

Definition at line 35 of file string_hash.hpp.

◆ operator()() [3/3]

size_t helios::utils::StringHash::operator() ( std::string_view str) const
inlinenodiscardnoexcept

Hashes a string-like object.

Parameters
strString to hash
Returns
Hash value

Definition at line 26 of file string_hash.hpp.