SharedStorage/utils/string/basic_utils.h

36 lines
684 B
C++

//
// Created by Kirill Zhukov on 20.04.2025.
//
#ifndef BASIC_UTILS_H
#define BASIC_UTILS_H
#include <sstream>
#include <iomanip>
namespace usub::utils
{
inline std::string to_string(const usub::utils::Hash128& hash)
{
std::ostringstream oss;
oss << std::hex << std::setfill('0')
<< std::setw(16) << hash.high
<< std::setw(16) << hash.low;
return oss.str();
}
}
namespace std
{
template <>
struct hash<usub::utils::Hash128>
{
size_t operator()(const usub::utils::Hash128& h) const noexcept
{
return static_cast<size_t>(h.high ^ h.low);
}
};
}
#endif //BASIC_UTILS_H