summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-30 15:04:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-30 15:04:40 +0000
commit4912476a6a13c0cf2291d35c5b8850d76c291abc (patch)
tree1a2b168d0ac3ff2675e4dc62c062d95e70923d12
parentMake Vertex constexpr (diff)
downloadilt-4912476a6a13c0cf2291d35c5b8850d76c291abc.tar.bz2
ilt-4912476a6a13c0cf2291d35c5b8850d76c291abc.tar.xz
ilt-4912476a6a13c0cf2291d35c5b8850d76c291abc.zip
Allow operator*= on spans, not just arrays
-rw-r--r--lib/collections.hpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/collections.hpp b/lib/collections.hpp
index beb01f8..b87cda3 100644
--- a/lib/collections.hpp
+++ b/lib/collections.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <array>
+#include <span>
template<typename T, std::size_t first, std::size_t second>
constexpr std::array<T, first + second>
@@ -39,11 +40,12 @@ operator*(const std::array<T, N> & in, auto && f)
return out;
}
-template<typename T, std::size_t N>
+template<typename T>
constexpr auto &
-operator*=(std::array<T, N> & in, auto && f)
+operator*=(std::span<T> & in, auto && f)
{
- for (const auto & v : in) {
+ for (auto & v : in) {
f(v);
}
+ return in;
}