From 10d9b4c98f984452eb1ff173d1e45b75a71a4ee5 Mon Sep 17 00:00:00 2001
From: Patrick Wuttke
Date: Mon, 22 Sep 2025 21:40:53 +0200
Subject: [PATCH] Made VectorMap find and access functions templates so you
don't have to construct the key.
---
source/mijin/container/vector_map.hpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/source/mijin/container/vector_map.hpp b/source/mijin/container/vector_map.hpp
index 53e5fb3..5fe5a08 100644
--- a/source/mijin/container/vector_map.hpp
+++ b/source/mijin/container/vector_map.hpp
@@ -133,7 +133,8 @@ public:
VectorMap& operator=(VectorMap&&) = default;
auto operator<=>(const VectorMap& other) const noexcept = default;
- TValue& operator[](const TKey& key)
+ template
+ TValue& operator[](const TIndex& key)
{
auto it = find(key);
if (it != end())
@@ -143,7 +144,8 @@ public:
return emplace(key, TValue()).first->second;
}
- const TValue& operator[](const TKey& key) const
+ template
+ const TValue& operator[](const TIndex& key) const
{
return at(key);
}
@@ -251,8 +253,9 @@ public:
return eraseImpl(idx, count);
}
+ template
[[nodiscard]]
- iterator find(const TKey& key) MIJIN_NOEXCEPT
+ iterator find(const TSearch& key) MIJIN_NOEXCEPT
{
for (std::size_t idx = 0; idx < keys_.size(); ++idx)
{
@@ -264,8 +267,9 @@ public:
return end();
}
+ template
[[nodiscard]]
- const_iterator find(const TKey& key) const MIJIN_NOEXCEPT
+ const_iterator find(const TSearch& key) const MIJIN_NOEXCEPT
{
for (std::size_t idx = 0; idx < keys_.size(); ++idx)
{