From 326e313d75643a344d93adf8544bdc9c8345cfe3 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 2 May 2022 08:42:07 +0200 Subject: [PATCH] copy-ctor for head-tail array with generic types --- libsrc/core/array.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libsrc/core/array.hpp b/libsrc/core/array.hpp index 0d01d172..3701a712 100644 --- a/libsrc/core/array.hpp +++ b/libsrc/core/array.hpp @@ -1525,6 +1525,9 @@ namespace ngcore public: HTArray () = default; HTArray (const HTArray &) = default; + template + HTArray (const HTArray & a2) : tail(a2.Tail()), head(a2.Head()) { ; } + HTArray & operator= (const HTArray &) = default; T * Ptr () { return tail.Ptr(); } @@ -1534,6 +1537,9 @@ namespace ngcore const T & operator[] (size_t i) const { return Ptr()[i]; } template T & Elem() { return (NR==S-1) ? head : tail.template Elem(); } + + auto Tail() const { return tail; } + auto Head() const { return head; } }; template @@ -1543,6 +1549,9 @@ namespace ngcore public: HTArray () = default; HTArray (const HTArray &) = default; + template + HTArray (const HTArray<1,T2> & a2) : head(a2.Head()) { ; } + HTArray & operator= (const HTArray &) = default; T * Ptr () { return &head; } @@ -1556,6 +1565,8 @@ namespace ngcore // assert(NR==0, "HTArray index error"); return head; } + + auto Head() const { return head; } }; template @@ -1565,6 +1576,9 @@ namespace ngcore public: HTArray () = default; HTArray (const HTArray &) = default; + template + HTArray (const HTArray<0,T2> & a2) { ; } + HTArray & operator= (const HTArray &) = default; /*