From 9378badf6bf629440f6e1a367be96777f6d8f074 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 30 Sep 2017 00:46:52 +0200 Subject: [PATCH] UI-Coordinates: integrate the initialisation split ...as developed in during the metaprogramming investigation --- src/lib/path-array.hpp | 77 +++++++++++++++++++++++++++++++--------- wiki/thinkPad.ichthyo.mm | 33 +++++++++++++++-- 2 files changed, 90 insertions(+), 20 deletions(-) diff --git a/src/lib/path-array.hpp b/src/lib/path-array.hpp index 9f3a73a5e..0fbb16993 100644 --- a/src/lib/path-array.hpp +++ b/src/lib/path-array.hpp @@ -49,10 +49,12 @@ #include "lib/error.hpp" #include "lib/symbol.hpp" #include "lib/iter-adapter.hpp" +#include "lib/meta/variadic-helper.hpp" #include "lib/util.hpp" //#include #include +#include #include #include #include @@ -61,6 +63,7 @@ namespace lib { // using std::unique_ptr; + using std::forward; using std::string; using lib::Literal; using util::unConst; @@ -88,6 +91,7 @@ namespace lib { return reinterpret_cast (p[0]); } + public: Extension() : storage_{nullptr} @@ -99,7 +103,8 @@ namespace lib { : storage_{new const char* [1 + sizeof...(ELMS)]} { size(storage_) = sizeof...(ELMS); - storage_[1] = {elms...}; + std::initializer_list lit{elms...}; + std::copy (begin(lit),end(lit), storage_+1); } ~Extension() @@ -161,6 +166,10 @@ namespace lib { + using meta::pickArg; + using meta::pickInit; + using meta::IndexSeq; + /** * Abstraction for path-like topological coordinates. * A sequence of Literal strings, with array-like access and @@ -170,31 +179,59 @@ namespace lib { template class PathArray { - using LiteralArray = std::array; + using Lit = const char*; + using LiteralArray = std::array; LiteralArray elms_; con::Extension tail_; + /** + * @internal delegate ctor to place the initialiser arguments appropriately + * @remarks the two index sequences passed by pattern match determine which + * arguments go to the inline array, and which go to heap allocated extension. + * The inline array has fixed size an is thus filled with trailing `NULL` ptrs, + * which is achieved with the help of meta::pickInit(). The con::Extension + * is an embedded smart-ptr, which, when receiving additional tail arguments, + * will place and manage them within a heap allocated array. + */ + template + PathArray (IndexSeq + ,IndexSeq + ,ARGS&& ...args) + : elms_{pickInit (forward(args)...) ...} + , tail_{pickArg (forward(args)...) ...} + { + this->normalise(); + } + + /** + * @internal rebinding helper for building sequences of index numbers, + * to route the initialiser arguments into the corresponding storage + * - the leading (`chunk_size`) arguments go into the LiteralArray inline + * - all the remaining arguments go into heap allocated extension storage + */ + template + struct Split + { + using Prefix = typename meta::BuildIndexSeq::Ascending; + using Rest = typename meta::BuildIdxIter::template After; + }; + public: template explicit PathArray (ARGS&& ...args) - : elms_{} - { - UNIMPLEMENTED ("initialise path array components"); - } + : PathArray(typename Split::Prefix() + ,typename Split::Rest() + ,forward (args)...) + { } - PathArray (PathArray const& o) - : elms_(o.elms_) - { - UNIMPLEMENTED ("copy construct path array components"); - } - - PathArray& - operator= (PathArray const& r) - { - UNIMPLEMENTED ("path array copy assignment"); - } + PathArray(PathArray&&) = default; + PathArray(PathArray const&) = default; + PathArray(PathArray& o) : PathArray((PathArray const&)o) { } + PathArray& operator= (PathArray const&) = default; + PathArray& operator= (PathArray &&) = default; + ////////////////////////TICKET #963 Forwarding shadows copy operations size_t @@ -258,6 +295,12 @@ namespace lib { { UNIMPLEMENTED ("path implementation storage"); } + + void + normalise() + { + UNIMPLEMENTED ("establish invariant"); + } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7ddc91a11..5ffe99778 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -3837,11 +3837,13 @@ - + + - + + @@ -3870,7 +3872,32 @@ - + + + + + + + + + + + + + + + + + +

+ VariadicArgumentPicker_test +

+ + +
+ +
+