Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::StringHash Struct Reference

A string hash functor that provides transparent hash operations for various string types. More...

#include <StringHash.hpp>

Public Types

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

Public Member Functions

std::size_t operator() (char const *str) const
 Computes the hash of a C-style string.
 
std::size_t operator() (std::string_view str) const
 Computes the hash of a string_view.
 
std::size_t operator() (std::string const &str) const
 Computes the hash of a standard string.
 

Detailed Description

A string hash functor that provides transparent hash operations for various string types.

This hash functor can be used with unordered containers to enable heterogeneous lookups for different string-like types without unnecessary conversions. It supports C-style strings, string views, and standard strings.

Member Function Documentation

◆ operator()() [1/3]

size_t util::StringHash::operator() ( char const * str) const

Computes the hash of a C-style string.

Parameters
strNull-terminated C-style string to hash
Returns
Size_t hash value

◆ operator()() [2/3]

size_t util::StringHash::operator() ( std::string const & str) const

Computes the hash of a standard string.

Parameters
strString to hash
Returns
Size_t hash value

◆ operator()() [3/3]

size_t util::StringHash::operator() ( std::string_view str) const

Computes the hash of a string_view.

Parameters
strString view to hash
Returns
Size_t hash value

The documentation for this struct was generated from the following files: