Invocation: complete closure-helper and tests
* now able to demonstrate close-front, close-back and close-argument * can also apply the same cases to `std::array`, with input and output type seamlessly adapted to `std::array`
This commit is contained in:
parent
89f839854c
commit
e014d88b2c
4 changed files with 112 additions and 39 deletions
|
|
@ -28,9 +28,10 @@
|
|||
** the setup-phase of the render network, while other parameters allow the user
|
||||
** to exert artistic control and will be supplied later, through automation.
|
||||
**
|
||||
** @see tuple-closure-test.cpp
|
||||
** @see weaving-pattern-builder.hpp
|
||||
** @see NodeBuilder_test::build_Node_closedParam()
|
||||
**
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -38,7 +39,6 @@
|
|||
#define LIB_META_TUPLE_CLOSURE_H
|
||||
|
||||
#include "lib/meta/function-closure.hpp"
|
||||
#include "lib/meta/tuple-helper.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <tuple>
|
||||
|
|
@ -170,6 +170,10 @@ namespace meta{
|
|||
{ }
|
||||
};
|
||||
|
||||
template<typename...TTT>
|
||||
ArrayAdapt(TTT...) -> ArrayAdapt<std::decay_t<TTT>...>;
|
||||
|
||||
|
||||
|
||||
/** partial specialisation to handle a std::array.
|
||||
* @note the expected input on partially closures
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ return: 0
|
|||
END
|
||||
|
||||
|
||||
PLANNED "tuple value pre-binding closure" TupleClosure_test <<END
|
||||
TEST "tuple value pre-binding closure" TupleClosure_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
|
|
|||
|
|
@ -25,9 +25,6 @@
|
|||
#include "lib/test/test-helper.hpp"
|
||||
#include "lib/meta/tuple-closure.hpp"
|
||||
#include "lib/format-util.hpp"
|
||||
#include "lib/test/diagnostic-output.hpp"////////////////TODO
|
||||
|
||||
|
||||
|
||||
|
||||
namespace lib {
|
||||
|
|
@ -47,6 +44,8 @@ namespace test {
|
|||
/*********************************************************************//**
|
||||
* @test wrap the constructors for »tuple-like« records as functor
|
||||
* and pre-bind some arguments immediately.
|
||||
* - verify binding flavours for a tuple with mixed types
|
||||
* - verify binding also works seamlessly with std::array
|
||||
*/
|
||||
class TupleClosure_test : public Test
|
||||
{
|
||||
|
|
@ -57,11 +56,12 @@ namespace test {
|
|||
tuple_bindBack();
|
||||
tuple_bindArg();
|
||||
array_bindFront();
|
||||
array_bindArg();
|
||||
verify_AdaptArray();
|
||||
}
|
||||
|
||||
|
||||
/** @test use a regular tuple and pre-fix the first elements
|
||||
*/
|
||||
/** @test use a regular tuple and pre-fix the first elements */
|
||||
void
|
||||
tuple_bindFront()
|
||||
{
|
||||
|
|
@ -78,8 +78,7 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** @test fix elements starting from the end of the tuple
|
||||
*/
|
||||
/** @test fix elements starting from the end of the tuple */
|
||||
void
|
||||
tuple_bindBack()
|
||||
{
|
||||
|
|
@ -99,8 +98,7 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** @test fix specific argument within tuple
|
||||
*/
|
||||
/** @test fix specific argument within tuple */
|
||||
void
|
||||
tuple_bindArg()
|
||||
{
|
||||
|
|
@ -119,8 +117,7 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** @test use a std::array and handle it like a tuple to pre-fix some elements
|
||||
*/
|
||||
/** @test use a std::array and handle it like a tuple to pre-fix some elements */
|
||||
void
|
||||
array_bindFront()
|
||||
{
|
||||
|
|
@ -128,12 +125,71 @@ namespace test {
|
|||
using Builder = TupleClosureBuilder<Arr>;
|
||||
|
||||
auto cons = Builder::closeFront (1u,2.3);
|
||||
using FunType = _Fun<decltype(cons)>;
|
||||
CHECK (showType<FunType::Sig>() == "ArrayAdapt<int, int, int, int, int> (ArrayAdapt<int, int, int>)"_expect);
|
||||
CHECK (showType<_Fun<decltype(cons)>::Sig>() == "ArrayAdapt<int, int, int, int, int> (ArrayAdapt<int, int, int>)"_expect);
|
||||
|
||||
Arr arr = cons({3,4,5});
|
||||
CHECK (arr == "[1, 2, 3, 4, 5]"_expect);
|
||||
}
|
||||
|
||||
|
||||
/** @test can also use the binding for arbitrary elements in a std::array */
|
||||
void
|
||||
array_bindArg()
|
||||
{
|
||||
using Arr = array<int,5>;
|
||||
using Builder = TupleClosureBuilder<Arr>;
|
||||
|
||||
auto cons = Builder::close<3>(55);
|
||||
CHECK (showType<_Fun<decltype(cons)>::Sig>() == "ArrayAdapt<int, int, int, int, int> (ArrayAdapt<int, int, int, int>)"_expect);
|
||||
|
||||
Arr arr = cons(array{1,2,3,4});
|
||||
CHECK (arr == "[1, 2, 3, 55, 4]"_expect);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @test verify properties of the metaprogramming-adapter,
|
||||
* used as seamless overlay to handle std::array
|
||||
* in the TUpleClosureBuilder.
|
||||
*/
|
||||
void
|
||||
verify_AdaptArray()
|
||||
{
|
||||
// can be constructed from aggregate
|
||||
ArrayAdapt arr{1,2,3,4,5};
|
||||
CHECK (arr.size() == 5);
|
||||
|
||||
// picks up a tuple-loke type signature
|
||||
using AA = decltype(arr);
|
||||
CHECK (showType<AA>() == "ArrayAdapt<int, int, int, int, int>"_expect );
|
||||
CHECK (showType<AA::value_type>() == "int"_expect );
|
||||
|
||||
// can use subscript operator from underlying array
|
||||
CHECK (arr[0] == 1);
|
||||
CHECK (arr[2] == 3);
|
||||
CHECK (arr[4] == 5);
|
||||
// can use the tuple-like binding defined for array
|
||||
CHECK (std::get<0>(arr) == 1);
|
||||
CHECK (std::get<2>(arr) == 3);
|
||||
CHECK (std::get<4>(arr) == 5);
|
||||
|
||||
// supports structured bindings
|
||||
auto& [v1,v2,v3,v4,v5] = arr;
|
||||
CHECK (v3 == 3);
|
||||
v3 = 33;
|
||||
CHECK (arr[2] == 33);
|
||||
|
||||
// can copy-assign from std::array
|
||||
arr = array{5,4,3,2,1};
|
||||
CHECK (arr[0] == 5);
|
||||
CHECK (arr[4] == 1);
|
||||
|
||||
// can copy/move-construct from std::array
|
||||
AA axx{array{-1,-2,-3,-4,-5}};
|
||||
CHECK (axx[0] == -1);
|
||||
CHECK (axx[2] == -3);
|
||||
CHECK (axx[4] == -5);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -58982,8 +58982,7 @@
|
|||
Achtung: perfect-forwarding in das Tuple-Remapping <i>hinein </i>wäre <font color="#d10606">gefährlich</font>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
|
|
@ -105959,7 +105958,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fafe99" COLOR="#fa002a" CREATED="1739644602379" ID="ID_1041155759" MODIFIED="1739644621556" TEXT="AUA. make_tuple kann kein Array bauen">
|
||||
<node BACKGROUND_COLOR="#dabe8f" COLOR="#bf1264" CREATED="1739644602379" ID="ID_1041155759" MODIFIED="1739834319487" TEXT="AUA. make_tuple kann kein Array bauen">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
<node CREATED="1739644626954" ID="ID_630391744" MODIFIED="1739644634662" TEXT="tja...">
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
|
|
@ -105976,7 +105975,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
<node CREATED="1739661467231" ID="ID_289562589" MODIFIED="1739661490167" TEXT="Parameter ist ein Value (ggfs Tupel)"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1739661519815" ID="ID_903309601" MODIFIED="1739661845721" TEXT="Anforderungen an einen Param-Transformer">
|
||||
<node COLOR="#435e98" CREATED="1739661519815" ID="ID_903309601" MODIFIED="1739834328519" TEXT="Anforderungen an einen Param-Transformer">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1739661533781" ID="ID_772896721" MODIFIED="1739661545552" TEXT="muß ausgabeseitig den exakt erwarteten Typ liefern">
|
||||
<node COLOR="#5b280f" CREATED="1739661547624" ID="ID_719316826" MODIFIED="1739661611083" TEXT="nicht bloß ein Tupel">
|
||||
|
|
@ -106037,11 +106036,15 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1739664341156" ID="ID_557298566" MODIFIED="1739664369471" TEXT="muß es in einem Anlauf schaffen...">
|
||||
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#435e98" CREATED="1739834354109" ID="ID_941625003" MODIFIED="1739834376741" TEXT="tatsächlich brauche ich eine äquivalente Funktion mit expliziter Signatur">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1739664371521" ID="ID_1608394291" MODIFIED="1739664384340" TEXT="brauche ein umschließendes Konstruktor-Template">
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1739664341156" ID="ID_557298566" MODIFIED="1739834271897" TEXT="muß es in einem Anlauf schaffen...">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node COLOR="#338800" CREATED="1739664371521" ID="ID_1608394291" MODIFIED="1739834398403" TEXT="brauche ein umschließendes Konstruktor-Template">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1739664387432" ID="ID_326201311" MODIFIED="1739664417960" TEXT="Zielvorgabe">
|
||||
<node CREATED="1739664419614" ID="ID_1229418497" MODIFIED="1739664419614" TEXT="wandert letztlich in den Weaving-Builder"/>
|
||||
<node CREATED="1739664421315" ID="ID_1529597389" MODIFIED="1739664441690" TEXT="soll die drei partial-closure-Primitive als Funktions-Templates bieten"/>
|
||||
|
|
@ -106076,16 +106079,15 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
d.h. man <i>kann</i> in der Praxis direkt mit einem Wert aufrufen, dann wird der eben implizit in ein 1-Tupel konvertiert
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1739742027076" ID="ID_1345350905" MODIFIED="1739742035927" TEXT="schrittweise verallgemeinern">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1739742027076" ID="ID_1345350905" MODIFIED="1739834260054" TEXT="schrittweise verallgemeinern">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1739742051151" ID="ID_240638029" MODIFIED="1739743700109" TEXT="Hindernis wegräumen: trailing NullType in Typsequenz der Funktions-Argumente">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node BACKGROUND_COLOR="#e6e1bd" CREATED="1739742093416" ID="ID_74503597" LINK="#ID_490359788" MODIFIED="1739743326711" TEXT="zugleich ein wichtiger Schritt für #987">
|
||||
|
|
@ -106106,8 +106108,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
<node COLOR="#435e98" CREATED="1739743706096" ID="ID_1310970069" MODIFIED="1739743735573" TEXT="das ist eigentlich generisch ⟹ umziehen in lib::meta::TupleClosureBuilder">
|
||||
<icon BUILTIN="yes"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1739752776321" ID="ID_376565948" MODIFIED="1739831050309" TEXT="TupleClosure_test zur Dokumentation">
|
||||
<node COLOR="#338800" CREATED="1739752776321" ID="ID_376565948" MODIFIED="1739833461512" TEXT="TupleClosure_test zur Dokumentation">
|
||||
<linktarget COLOR="#5fcdb6" DESTINATION="ID_376565948" ENDARROW="Default" ENDINCLINATION="-22;74;" ID="Arrow_ID_1770813109" SOURCE="ID_656057721" STARTARROW="None" STARTINCLINATION="-338;20;"/>
|
||||
<linktarget COLOR="#5fcdb6" DESTINATION="ID_376565948" ENDARROW="Default" ENDINCLINATION="-22;74;" ID="Arrow_ID_1966862235" SOURCE="ID_678284468" STARTARROW="None" STARTINCLINATION="-433;35;"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1739822405519" ID="ID_1159986625" MODIFIED="1739822418374" TEXT="weitere partial-closure-Fälle integrieren">
|
||||
|
|
@ -106120,8 +106123,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
wie steht's mit <i>perfect forwarding</i>?
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
<font NAME="SansSerif" SIZE="12"/>
|
||||
<icon BUILTIN="help"/>
|
||||
<node CREATED="1739822460457" ID="ID_813032583" MODIFIED="1739822493962">
|
||||
|
|
@ -106132,8 +106134,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
ohnehin limitiert: wir konstruieren stets Werte <i>in den Binder</i>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node COLOR="#5b280f" CREATED="1739822514329" ID="ID_304319384" MODIFIED="1739822915159" TEXT="TupleConstructor?">
|
||||
|
|
@ -106149,8 +106150,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
...das bedeutet, der ElmMapper greift auf Inhalte zu, so wie sie im ctor-Argument des TupleConstructors liegen. Aber, da das Tupel selber per L-Value-Referenz eingebunden ist, wird auch std::get nur eine LValue-Referenz herausgeben (selbst wenn im Tupel selber eine RValue-Referenz liegen würde...). Das wäre nur anders, wenn man <i>das ganze Tupel</i> als RValue-Referenz an std::get gäbe...
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="info"/>
|
||||
</node>
|
||||
<node CREATED="1739822742383" ID="ID_1631025117" MODIFIED="1739827057895">
|
||||
|
|
@ -106207,8 +106207,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1739756728914" ID="ID_1671606956" MODIFIED="1739813490672" TEXT="Auf std::array anwendbar machen">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1739756728914" ID="ID_1671606956" MODIFIED="1739834257328" TEXT="Auf std::array anwendbar machen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1739756741667" ID="ID_20824263" MODIFIED="1739816589487" TEXT="Problem: spezielle Typsignatur">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1739756760373" ID="ID_753184722" MODIFIED="1739756775186" TEXT="deshalb ist in jedem Fall eine partielle Spezialisierung notwendig"/>
|
||||
|
|
@ -106244,12 +106244,25 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
<node COLOR="#338800" CREATED="1739816632434" ID="ID_1046144111" MODIFIED="1739816647386" TEXT="Aggregat-Initialisierung ermöglichen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1739816653616" ID="ID_1737045068" MODIFIED="1739816676602" TEXT="Tuple-Protocol wird unterstützt">
|
||||
<icon BUILTIN="flag-pink"/>
|
||||
<node COLOR="#338800" CREATED="1739830994738" ID="ID_678284468" MODIFIED="1739833461512" TEXT="Tuple-Protocol wird unterstützt">
|
||||
<arrowlink COLOR="#5fcdb6" DESTINATION="ID_376565948" ENDARROW="Default" ENDINCLINATION="-22;74;" ID="Arrow_ID_1966862235" STARTARROW="None" STARTINCLINATION="-433;35;"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1739834426148" ID="ID_116229103" MODIFIED="1739834437076" TEXT="kann nun alle Binding-Fälle generisch handhaben">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1739834442174" ID="ID_1999526476" MODIFIED="1739834476493" TEXT="in WeavingBuilder per Typedef einbinden">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1739834455793" ID="ID_1242451785" MODIFIED="1739834478061" TEXT="kann direkt an die jeweilige Impl-Funktion dort delegieren">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1739834479509" ID="ID_175725143" MODIFIED="1739834488796" TEXT="Lösung ist kaskadierbar auf Ergebnis">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue