lumiera_/doc/technical
Ichthyostega b6bdcc068d Library: investigate how a »zip iterator« can be built
Basically I am sick of writing for-loops in those cases
where the actual iteration is based on one or several data sources,
and I just need some damn index counter. Nothing against for-loops
in general — they have their valid uses — sometimes a for-loop is KISS

But in these typical cases, an iterator-based solution would be a
one-liner, when also exploiting the structured bindings of C++17

''I must admit that I want this for a loooooong time —''
...but always got intimidated again when thinking through the fine points.
Basically it „should be dead simple“ — as they say

Well — — it ''is'' simple, after getting the nasty aspects of tuple binding
and reference data types out of the way. Yesterday, while writing those
`TestFrame` test cases (which are again an example where you want to iterate
over two word sequences simultaneously and just compare them), I noticed that
last year I learned about the `std::apply`-to-fold-expression trick, and
that this solution pattern could be adapted to construct a tuple directly,
thereby circumventing most of the problems related to ''perfect forwarding''

So now we have a new util function `mapEach` (defined in `tuple-helper.hpp`)
and I have learned how to make this application completely generic.

As a second step, I implemented a proof-of-concept in `IterZip_test`,
which indeed was not really challenging, because the `IterExplorer`
is so very sophisticated by now and handles most cases with transparent
type-driven adaptors. A lot of work went into `IterExplorer` over the years,
and this pays off now.

The solution works as follows:
 * apply the `lib::explore()` constructor function to the varargs
 * package the resulting `IterExplorer` instantiations into a tuple
 * build a »state core« implementation which just lifts out the three
   iterator primitives onto this ''product type'' (i.e. the tuple)
 * wrap it in yet another `IterExplorer`
 * add a transformer function on top to extract a value-tuple for each ''yield'

As expected, works out-of-the-box, with all conceivable variants and wild
mixes of iterators, const, pointers, references, you name it....

PS: I changed the rendering of unsigned types in diagnostic output
    to use the short notation, e.g. `uint` instead of `unsigned int`.
    This dramatically improves the legibility of verification strings.
2024-11-22 22:07:39 +01:00
..
build Project: switch to C++17 (closes: #1138) 2020-02-21 21:10:51 +01:00
code Library: shorten display of unsigned types 2024-11-22 22:02:45 +01:00
howto Library: investigate how a »zip iterator« can be built 2024-11-22 22:07:39 +01:00
infra Global-Layer-Renaming: fix remaining textual usages and IDs in the code 2018-12-10 00:09:56 +01:00
library Timeline: document use of custom CSS rules 2023-03-17 01:10:33 +01:00
stage Timeline: document use of custom CSS rules 2023-03-17 01:10:33 +01:00
steam Global-Layer-Renaming: rearrange directories 2018-11-15 23:28:03 +01:00
vault Global-Layer-Renaming: fix remaining textual usages and IDs in the code 2018-12-10 00:09:56 +01:00
DIR_INFO update some DIR_INFO entries 2011-04-05 00:44:30 +02:00
index.txt Global-Layer-Renaming: rearrange directories 2018-11-15 23:28:03 +01:00
overview.txt Invocation: capture idea for sharpened invocation structure 2024-05-12 17:27:07 +02:00