ATLAS Offline Software
Loading...
Searching...
No Matches
transparent_string_hash.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3 */
4#ifndef CXXUTILS_TRANSPARENT_STRING_HASH_H
5#define CXXUTILS_TRANSPARENT_STRING_HASH_H
6
7#include <cstddef>
8#include <functional> // std::hash
9#include <string>
10#include <string_view>
11
12namespace CxxUtils {
13
61 using is_transparent = void;
62
68 std::size_t
69 operator()(std::string_view s) const{
70 return std::hash<std::string_view>{}(s);
71 }
72
78 std::size_t
79 operator()(const std::string& s) const{
80 return (*this)(std::string_view{s});
81 }
82
88 std::size_t
89 operator()(const char* s) const{
90 return (*this)(std::string_view{s});
91 }
92 };
93
94} // namespace CxxUtils
95
96#endif
Transparent hash functor for string-like keys.
std::size_t operator()(const std::string &s) const
Hash a string.
std::size_t operator()(const char *s) const
Hash a C string.
std::size_t operator()(std::string_view s) const
Hash a string view.