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
20 public:
26 explicit ArtifactKey(std::string key) : key_{std::move(key)} {}
27
28 [[nodiscard]] const std::string &key() const
29 {
30 return key_;
31 }
32
33 [[nodiscard]] bool operator==(const ArtifactKey &other) const = default;
34
35 [[nodiscard]] auto operator<=>(const ArtifactKey &other) const = default;
36
37 private:
38 std::string key_;
39};
40
41} // namespace porytiles
42
43// Hash specialization for std::unordered_map support
44template <>
45struct std::hash<porytiles::ArtifactKey> {
46 std::size_t operator()(const porytiles::ArtifactKey &key) const noexcept
47 {
48 return std::hash<std::string>{}(key.key());
49 }
50};
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