Porytiles
Loading...
Searching...
No Matches
artifact_key.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <compare>
4#include <functional>
5#include <string>
6
7namespace porytiles {
8
18 public:
22 explicit ArtifactKey(std::string key) : key_{std::move(key)} {}
23
24 [[nodiscard]] const std::string &key() const
25 {
26 return key_;
27 }
28
29 [[nodiscard]] bool operator==(const ArtifactKey &other) const = default;
30
31 [[nodiscard]] auto operator<=>(const ArtifactKey &other) const = default;
32
33 private:
34 std::string key_;
35};
36
37} // namespace porytiles
38
39// Hash specialization for std::unordered_map support
40template <>
41struct std::hash<porytiles::ArtifactKey> {
42 std::size_t operator()(const porytiles::ArtifactKey &key) const noexcept
43 {
44 return std::hash<std::string>{}(key.key());
45 }
46};
A type-safe wrapper for artifact keys.
ArtifactKey(std::string key)
Constructs an ArtifactKey from a string value.
auto operator<=>(const ArtifactKey &other) const =default
const std::string & key() const
bool operator==(const ArtifactKey &other) const =default
std::size_t operator()(const porytiles::ArtifactKey &key) const noexcept