aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/types/Date.hpp
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2024-01-01 04:32:01 +0100
committer GitHub <noreply@github.com>2024-01-01 04:32:01 +0100
commit9988b21278dc1c8df044631bd2935a7e450a7bff (patch)
treeba081f9f4d74865ab5851a2efd560745900ca81a /src/openvic-simulation/types/Date.hpp
parent0a425fbe05d6138b753c0e4a7c06f06695bde8af (diff)
parente1496a87178d925277aceed0ebcbab06920e15ee (diff)
Merge pull request #105 from OpenVicProject/add/ordered-map
Diffstat (limited to 'src/openvic-simulation/types/Date.hpp')
-rw-r--r--src/openvic-simulation/types/Date.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/openvic-simulation/types/Date.hpp b/src/openvic-simulation/types/Date.hpp
index 3dc6dab..2bf08e8 100644
--- a/src/openvic-simulation/types/Date.hpp
+++ b/src/openvic-simulation/types/Date.hpp
@@ -1,10 +1,12 @@
#pragma once
+#include <climits>
#include <cstdint>
#include <ostream>
#include <string>
#include "openvic-simulation/utility/Getters.hpp"
+#include "openvic-simulation/utility/Utility.hpp"
namespace OpenVic {
// A relative period between points in time, measured in days
@@ -107,3 +109,14 @@ namespace OpenVic {
};
std::ostream& operator<<(std::ostream& out, Date date);
}
+
+namespace std {
+ template<>
+ struct hash<OpenVic::Date> {
+ [[nodiscard]] size_t operator()(OpenVic::Date date) const {
+ size_t result = 0;
+ OpenVic::utility::perfect_hash(result, date.get_day(), date.get_month(), date.get_year());
+ return result;
+ }
+ };
+} \ No newline at end of file