LUMIERA.clone/doc/technical/howto
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
..
backporting.txt Switch to HTTPS: also adjust protocol for the ASCIIDOC generated links 2018-10-26 17:47:18 +02:00
crackNuts.txt Library: investigate how a »zip iterator« can be built 2024-11-22 22:07:39 +01:00
DebugGdbPretty.txt DOC: small howto improvements 2014-12-01 01:31:19 +01:00
HashFunctions.txt Invocation: build test-data manipulation function 2024-11-21 00:50:39 +01:00
IdeSetup.txt DOC: fill in explanations for all subsystems (closes #1145) 2020-02-23 08:21:22 +01:00
index.txt write down some know-how regarding standard hash functions 2011-10-14 01:10:16 +02:00
UsingBoost.txt Library: replace boost::noncopyable by our own library solution 2018-03-24 05:35:13 +01:00