TreeExplorer: prototype for the extracted boilerplate helper
a quite convoluted construct built from several nested generic lambdas. When investigated in the debugger, the observed addresses and the invoked code looks sane and as expected.
This commit is contained in:
parent
b4edf8e33c
commit
8f70b4e902
3 changed files with 88 additions and 32 deletions
|
|
@ -911,34 +911,6 @@ namespace lib {
|
|||
}
|
||||
|
||||
|
||||
/* === Remould the Filter condition underway === */
|
||||
|
||||
template<typename COND>
|
||||
void
|
||||
andFilter (COND conjunctiveClause)
|
||||
{
|
||||
using _ChainTraits = _BoundFunctor<COND,SRC>;
|
||||
using Res = typename _ChainTraits::Res;
|
||||
static_assert(std::is_constructible<bool, Res>::value, "Chained Functor must be a predicate");
|
||||
|
||||
using ChainPredicate = typename _ChainTraits::Functor;
|
||||
|
||||
FilterPredicate& firstClause = this->predicate_;
|
||||
ChainPredicate chainClause{forward<COND> (conjunctiveClause)};
|
||||
|
||||
auto buildCombinedClause = [](auto first, auto second)
|
||||
{
|
||||
return [=](auto val)
|
||||
{
|
||||
return first(val)
|
||||
and second(val);
|
||||
};
|
||||
};
|
||||
|
||||
predicate_ = FilterPredicate{buildCombinedClause (firstClause, chainClause)};
|
||||
pullFilter();
|
||||
}
|
||||
|
||||
private:
|
||||
SRC&
|
||||
srcIter() const
|
||||
|
|
@ -955,6 +927,44 @@ namespace lib {
|
|||
while (srcIter() and not predicate_(srcIter()))
|
||||
++srcIter();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public: /* === API to Remould the Filter condition underway === */
|
||||
|
||||
template<typename COND>
|
||||
void
|
||||
andFilter (COND&& conjunctiveClause)
|
||||
{
|
||||
remouldFilter (forward<COND> (conjunctiveClause)
|
||||
,[](auto first, auto chain)
|
||||
{
|
||||
return [=](auto val)
|
||||
{
|
||||
return first(val)
|
||||
and chain(val);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
template<typename COND, class COMB>
|
||||
void
|
||||
remouldFilter (COND&& additionalClause, COMB buildCombinedClause)
|
||||
{
|
||||
using _ChainTraits = _BoundFunctor<COND,SRC>;
|
||||
using Res = typename _ChainTraits::Res;
|
||||
static_assert(std::is_constructible<bool, Res>::value, "Chained Functor must be a predicate");
|
||||
|
||||
using ChainPredicate = typename _ChainTraits::Functor;
|
||||
|
||||
FilterPredicate& firstClause = this->predicate_;
|
||||
ChainPredicate chainClause{forward<COND> (additionalClause)};
|
||||
|
||||
predicate_ = FilterPredicate{buildCombinedClause (firstClause, chainClause)};
|
||||
pullFilter();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -865,6 +865,8 @@ namespace test{
|
|||
|
||||
seq.andFilter (takeEve);
|
||||
CHECK (18 == *seq);
|
||||
++seq;
|
||||
CHECK (16 == *seq);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30974,7 +30974,9 @@
|
|||
</richcontent>
|
||||
<icon BUILTIN="button_cancel"/>
|
||||
</node>
|
||||
<node CREATED="1535906261464" ID="ID_1343076549" MODIFIED="1535906264259" TEXT="Auswege">
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1535906261464" ID="ID_1343076549" MODIFIED="1535909947735" TEXT="Auswege">
|
||||
<icon BUILTIN="idea"/>
|
||||
<node CREATED="1535906265911" ID="ID_442265155" MODIFIED="1535906279633" TEXT="speziellen Filter-Layer nur hierfür">
|
||||
<node CREATED="1535906327782" ID="ID_1903350743" MODIFIED="1535906334769" TEXT="letztlich nur Code-Kosmetik"/>
|
||||
<node CREATED="1535909106704" ID="ID_1756811057" MODIFIED="1535909115714" TEXT="würde aber sehr speziellen Fall markieren"/>
|
||||
|
|
@ -30988,12 +30990,12 @@
|
|||
Name: <b>mutableFilter</b>()
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1535906283948" ID="ID_367978731" MODIFIED="1535906294727" TEXT="Chain-Filter-Bau in HIlfsfunktion">
|
||||
<node COLOR="#338800" CREATED="1535906283948" ID="ID_367978731" MODIFIED="1535909918916" TEXT="Chain-Filter-Bau in HIlfsfunktion">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1535906394646" ID="ID_296637778" MODIFIED="1535906399057" TEXT="wünschenswert"/>
|
||||
<node CREATED="1535906399621" ID="ID_1487063274" MODIFIED="1535906407632" TEXT="nicht klar, ob überhaupt möglich"/>
|
||||
<node CREATED="1535909021163" ID="ID_1776922208" MODIFIED="1535909030226" TEXT="geschachtelte generische Lambdas verwenden">
|
||||
|
|
@ -31002,6 +31004,48 @@
|
|||
<node CREATED="1535909041497" ID="ID_911444458" MODIFIED="1535909052069" TEXT="AUA³">
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
<node CREATED="1535909192572" ID="ID_1938820560" MODIFIED="1535909197055" TEXT="aber es geht...."/>
|
||||
<node COLOR="#338800" CREATED="1535909967725" ID="ID_745154448" MODIFIED="1535912743392" TEXT="im Debugger verifizieren!">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
...sieht gut aus.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
Folgendes habe ich gesehen
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
zu Beginn zeigt das eingebettete Funktor-Objekt auf eine Position auf dem Stack
|
||||
</li>
|
||||
<li>
|
||||
beim Aufrufen der andFilter()-Funktion werden diverse Funktoren kopiert,<br />wobei nacheinander die (zu erwartenden) Argumente als Quelle auftauchen<br />
|
||||
</li>
|
||||
<li>
|
||||
danach hat sich der Funktor geändert: er zeigt nun auf eine Position auf dem Heap<br />
|
||||
</li>
|
||||
<li>
|
||||
der bisherige Funktor wurde mit der Closure des zusammengesetzten Funktors kollabiert (hat gleiche Addresse)<br />
|
||||
</li>
|
||||
<li>
|
||||
der Chain-Funktor hat eine Closure bekommen, die ebenfalls Heap-alloziert ist.<br />das deutet darauf hin, daß das capturen per copy funktioniert hat<br />
|
||||
</li>
|
||||
<li>
|
||||
Beim Aufruf steppen wir nacheinander erst in den kombinierten Funktor,<br />und von dort wie erwartet in die beiden Lambdas.
|
||||
</li>
|
||||
<li>
|
||||
<br />
|
||||
</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue