Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
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 16 of file string_hash.hpp.

Member Typedef Documentation

◆ hash_type

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

Definition at line 18 of file string_hash.hpp.

◆ is_transparent

Enables heterogeneous lookup.

Definition at line 17 of file string_hash.hpp.

Member Function Documentation

◆ operator()() [1/3]

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

Hashes a C-style string.

Parameters
strString to hash
Returns
Hash value

Definition at line 39 of file string_hash.hpp.

39{ return hash_type{}(str); }
std::hash< std::string_view > hash_type

◆ operator()() [2/3]

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

Hashes a std::string.

Parameters
strString to hash
Returns
Hash value

Definition at line 32 of file string_hash.hpp.

32{ return hash_type{}(str); }

◆ operator()() [3/3]

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

Hashes a string-like object.

Parameters
strString to hash
Returns
Hash value

Definition at line 25 of file string_hash.hpp.

25{ return hash_type{}(str); }