mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 11:52:08 +07:00
remove hashed_string class
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
#include "meta_base/fixed_function.hpp"
|
||||
#include "meta_base/fnv1a_hash.hpp"
|
||||
#include "meta_base/hash_composer.hpp"
|
||||
#include "meta_base/hashed_string.hpp"
|
||||
#include "meta_base/inline_vector.hpp"
|
||||
#include "meta_base/insert_or_assign.hpp"
|
||||
#include "meta_base/is_in_place_type.hpp"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "base.hpp"
|
||||
#include "bitflags.hpp"
|
||||
#include "fnv1a_hash.hpp"
|
||||
#include "hashed_string.hpp"
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
@@ -40,7 +39,7 @@ namespace meta_hpp::detail
|
||||
}
|
||||
|
||||
constexpr hash_composer operator<<(std::string_view value) noexcept {
|
||||
hash = combine(hash, hashed_string{value}.get_hash());
|
||||
hash = combine(hash, fnv1a_hash(value.data(), value.size()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021-2024, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base.hpp"
|
||||
#include "fnv1a_hash.hpp"
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
class hashed_string final {
|
||||
public:
|
||||
hashed_string() = default;
|
||||
~hashed_string() = default;
|
||||
|
||||
hashed_string(hashed_string&&) = default;
|
||||
hashed_string(const hashed_string&) = default;
|
||||
|
||||
hashed_string& operator=(hashed_string&&) = default;
|
||||
hashed_string& operator=(const hashed_string&) = default;
|
||||
|
||||
constexpr hashed_string(std::string_view str) noexcept
|
||||
: hash_{fnv1a_hash(str.data(), str.size())} {}
|
||||
|
||||
constexpr void swap(hashed_string& other) noexcept {
|
||||
std::swap(hash_, other.hash_);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::size_t get_hash() const noexcept {
|
||||
return hash_;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator==(hashed_string other) const noexcept {
|
||||
return hash_ == other.hash_;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::strong_ordering operator<=>(hashed_string other) const noexcept {
|
||||
return hash_ <=> other.hash_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t hash_{fnv1a_hash("", 0)};
|
||||
};
|
||||
|
||||
constexpr void swap(hashed_string& l, hashed_string& r) noexcept {
|
||||
l.swap(r);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator==(hashed_string l, std::string_view r) noexcept {
|
||||
return l == hashed_string{r};
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::strong_ordering operator<=>(hashed_string l, std::string_view r) noexcept {
|
||||
return l <=> hashed_string{r};
|
||||
}
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<meta_hpp::detail::hashed_string> {
|
||||
size_t operator()(meta_hpp::detail::hashed_string hs) const noexcept {
|
||||
return hs.get_hash();
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user