From d30757fb3534b4f053e9da2e3ba35323b508e339 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 5 Mar 2023 02:39:16 +0000 Subject: Replace SelectionT for glm::vec with one for std::span, reimplement it as a wrapper All the implementation is now shared, regardless of length and qualifier. --- lib/persistence.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/persistence.h b/lib/persistence.h index 05cb49b..35d60ca 100644 --- a/lib/persistence.h +++ b/lib/persistence.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -201,9 +202,8 @@ namespace Persistence { bool shared; }; - template - struct SelectionT> : public SelectionV> { - using V = glm::vec; + template struct SelectionT> : public SelectionV> { + using V = std::span; struct Members : public SelectionV { using SelectionV::SelectionV; @@ -214,12 +214,12 @@ namespace Persistence { stk.push(SelectionV::make(this->v[idx++])); } - glm::length_t idx {0}; + std::size_t idx {0}; void write(const Writer & out) const override { - for (glm::length_t n = 0; n < L; n += 1) { + for (std::size_t n = 0; n < this->v.size(); n += 1) { if (n) { out.nextValue(); } @@ -235,7 +235,7 @@ namespace Persistence { setValue(std::string && s) override { std::stringstream ss {std::move(s)}; - for (glm::length_t n = 0; n < L; n += 1) { + for (std::size_t n = 0; n < this->v.size(); n += 1) { ss >> this->v[n]; ss.get(); } @@ -256,6 +256,12 @@ namespace Persistence { } }; + template + struct SelectionT> : public SelectionT> { + SelectionT(glm::vec & v) : SelectionT> {spn}, spn {&v[0], L} { } + std::span spn; + }; + template struct SelectionT> : public SelectionV> { using V = std::vector; -- cgit v1.2.3