From 7d35790e1152d103acd7432c33bc09d0933e4708 Mon Sep 17 00:00:00 2001
From: Ichthyostega
Date: Sun, 19 Jul 2026 23:44:30 +0200
Subject: [PATCH] Parameters: implement simple value extraction for base types
...so this is not yet a visitor, rather the building blocks required
to be able to extract values and to assign and conform values
And my intention is to build something akin to a set of conversion rules
---
src/lib/par/domain.hpp | 51 ++++++++++++++---
tests/lib/par/parameter-domain-test.cpp | 16 ++++--
wiki/thinkPad.ichthyo.mm | 76 ++++++++++++++++++++++---
3 files changed, 123 insertions(+), 20 deletions(-)
diff --git a/src/lib/par/domain.hpp b/src/lib/par/domain.hpp
index 37603ed28..fbf15c47a 100644
--- a/src/lib/par/domain.hpp
+++ b/src/lib/par/domain.hpp
@@ -37,6 +37,7 @@
#include "lib/meta/typelist.hpp"
//#include "lib/meta/typelist-util.hpp"
#include "lib/meta/generator.hpp"
+#include "lib/meta/trait.hpp"
namespace lib {
@@ -60,11 +61,28 @@ namespace par {
return * static_cast (rawMem);
}
+ template
+ constexpr inline X&
+ asValue (ValBuff& storage)
+ {
+ void* rawMem{& storage};
+ return * static_cast (rawMem);
+ }
+
+ template
+ constexpr inline X const&
+ asValue (ValBuff const& storage)
+ {
+ void const * rawMem{& storage};
+ return * static_cast (rawMem);
+ }
+
+
template
class TypeHandler
{
public:
- virtual void extractAs (X&, ValBuff&) =0;
+ virtual void extractAs (X&, ValBuff const&) =0;
};
// using lib::meta::typeseq;
@@ -113,18 +131,14 @@ _Pragma("GCC diagnostic ignored \"-Woverloaded-virtual\"")
template
- struct TypeDomainSetup
+ struct TypeSetup
{
template
class TypeHandlerImpl
: public BAS
{
- void
- extractAs (X& srcVal, ValBuff& valBuff) override
- {
- UNIMPLEMENTED ("extract into Buffer");
- }
+ void extractAs (X& targetVal, ValBuff const& valBuff) override;
};
using TypeHandlerChain = meta::InstantiateChained;
@@ -134,12 +148,33 @@ _Pragma("GCC diagnostic ignored \"-Woverloaded-virtual\"")
template
class BaseDomain
- : public TypeDomainSetup::TypeHandlerChain
+ : public TypeSetup::TypeHandlerChain
{
public:
};
+ /* ===== type conversion details ===== */
+
+ template
+ template
+ inline void
+ TypeSetup::TypeHandlerImpl::extractAs (X& targetVal, ValBuff const& valBuff)
+ {
+ if constexpr (std::is_assignable_v)
+ {
+ targetVal = asValue (valBuff);
+ }
+ else
+ if constexpr (std::is_constructible_v)
+ {
+ targetVal.~X();
+ new(&targetVal) X (asValue (valBuff));
+ }
+ else
+ static_assert (!sizeof(X), "this type conversion is not supported");
+ }
+
}} // namespace lib::par
#endif /*LIB_PAR_DOMAIN_H*/
diff --git a/tests/lib/par/parameter-domain-test.cpp b/tests/lib/par/parameter-domain-test.cpp
index 926fc1e48..8a9cbee24 100644
--- a/tests/lib/par/parameter-domain-test.cpp
+++ b/tests/lib/par/parameter-domain-test.cpp
@@ -19,7 +19,7 @@
#include "test/run.hpp"
//#include "test/test-helper.hpp"
#include "lib/par/domain.hpp"
-//#include "lib/format-cout.hpp"
+#include "test/diagnostic-output.hpp"////////////TODO
//#include
//#include
@@ -70,7 +70,7 @@ namespace test{
{
seedRand();
basics();
- verify_typeVisitor();
+ verify_valueAccess();
}
@@ -81,7 +81,7 @@ namespace test{
void
- verify_typeVisitor()
+ verify_valueAccess()
{
BaseDomain domInt;
Domain& d1{domInt};
@@ -92,9 +92,15 @@ namespace test{
uint target1{0};
CHECK (not target1);
- TypeHandler& dd1{d1};
- dd1.extractAs (target1, src1);
+ TypeHandler& du1{d1};
+ du1.extractAs (target1, src1);
CHECK (target1 == uint(val1));
+
+ float target2{0};
+
+ TypeHandler& df1{d1};
+ df1.extractAs (target2, src1);
+ CHECK (target2 == float(val1));
}
};
diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm
index 2c5fd8e07..b899cb9c8 100644
--- a/wiki/thinkPad.ichthyo.mm
+++ b/wiki/thinkPad.ichthyo.mm
@@ -82879,7 +82879,15 @@
-
+
+
+
+
+
+ allerdings darf der Aufruf selber keine Ambiguität erzueugen...
+
+
+
@@ -82907,6 +82915,7 @@
+
@@ -82994,7 +83003,45 @@
-
+
+
+
+
+
+
+
+
+
+
+
+ das ist noch kein Visitor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Glaube nicht, daß ich mich damit aufhalten sollte; das führt direkt in das lästige Thema mit den automatischen Konversionen zwischen Basistypen — wenn überhaupt sollte eine Spezialbehandlung dafür in ein Regelwerk gelenkt werden (und darauf ziehlt doch das ganze Setup mit dem Visitor ab....)
+
+
+
+
+
+
+
+
@@ -184216,7 +184263,7 @@ class Something
-
+
@@ -184260,7 +184307,11 @@ class Something
-
+
+
+
+
+
@@ -184303,12 +184354,12 @@ class Something
-
+
- die Requires-Klausel darf nicht scheitern
+ die Requires-Klausel darf nicht scheitern; insofern muß das Argument der Requires-Klausel (≙ ein constraint oder concept) syntaktisch korrekt gebildet werden können, und es muß zur Compile-Zeit zu true evaluieren.
@@ -184324,9 +184375,20 @@ class Something
+
+
+
+
+
+ Das ist eine Requires-Klausel die einen anonymen Constraint prüft (der als eingeschachtelter Requires-Ausdruck formuliert wurde)
+
+
+
+
-
+
+