Library: draft a scheme to configure lib::Several with a custom allocator

Phew... this was a tough one — and not sure yet if this even remotely works...

Anyway, the `lib::SeveralBuilder` is already prepared for collaboration with a
custom allocator, since it delegates all memory handling through a base policy,
which in turn relies on std::allocator_traits.

The challenge however is to find a way...
 * to make this clear and easy to use
 * to expose an extension point for specific tweaks
 * and to make all this work without excessive header cross dependencies
This commit is contained in:
Fischlurch 2024-06-15 01:14:42 +02:00
parent bb164e37c8
commit d327094603
6 changed files with 458 additions and 61 deletions

View file

@ -37,6 +37,11 @@
** including the invocation of their destructors, while relying on the allocator
** to allot and discard bare memory. However, to avoid invoking any destructors,
** the container itself can be created with AllocationCluster::createDisposable.
** \par dynamic adjustments
** Under controlled conditions, it is possible to change the size of the latest
** raw allocation handed out, within the limits of the available reserve in the
** current memory extent. Obviously, this is a dangerous low-level feature, yet
** offers some flexibility for containers and allocation schemes built on top.
** @warning deliberately *not threadsafe*.
** @remark confine usage to a single thread or use thread-local clusters.
** @see allocation-cluster-test.cpp
@ -269,7 +274,7 @@ namespace lib {
AllocationCluster::Storage::adjustPos (int offset) ///< @warning be sure a negative offset is properly limited
{
REQUIRE (pos);
REQUIRE (hasReserve (rest));
REQUIRE (hasReserve (offset));
pos = bytePos() + offset;
rest -= offset;
}
@ -287,5 +292,52 @@ namespace lib {
}
//-----Policies-to-use-AllocationCluster------------------------
namespace {
// Forward declaration: configuration policy for lib::SeveralBuilder
template<class I, class E, template<typename> class ALO>
struct AllocationPolicy;
}
namespace allo { // Setup for custom allocator policies
template<template<typename> class ALO, typename...ARGS>
struct SetupSeveral;
/**
* Specialisation to use lib::Several with storage managed by an
* AllocationCluster instance, which must be provided as argument.
* \code
* AllocationCluster clu;
* using Data = ....
* Several<Data> elms = makeSeveral<Data>()
* .withAllocator(clu)
* .fillElm(5)
* .build();
* \endcode
*/
template<>
struct SetupSeveral<std::void_t, lib::AllocationCluster&>
{
template<typename X>
using Adapter = typename AllocationCluster::template Allocator<X>;
template<class I, class E>
struct Policy
: AllocationPolicy<I,E,Adapter>
{
Policy (AllocationCluster& clu)
: AllocationPolicy<I,E,Adapter> (clu.getAllocator<std::byte>())
{ }
};
};
//
}//(End)Allocator configuration
} // namespace lib
#endif /*LIB_ALLOCATION_CLUSTER_H*/

View file

@ -336,6 +336,13 @@ namespace lib {
/* ===== Builder API ===== */
/** cross-builder to use a custom allocator for the lib::Several container */
template<template<typename> class ALO =std::void_t
,typename...ARGS>
auto withAllocator (ARGS&& ...args);
/** ensure sufficient memory allocation up-front */
template<typename TY =E>
SeveralBuilder&&
reserve (size_t cntElm =1
@ -348,6 +355,7 @@ namespace lib {
return move(*this);
}
/** append copies of one or several arbitrary elements */
template<typename VAL, typename...VALS>
SeveralBuilder&&
append (VAL&& val, VALS&& ...vals)
@ -359,6 +367,7 @@ namespace lib {
return move(*this);
}
/** append a copy of all values exposed through an iterator */
template<class IT>
SeveralBuilder&&
appendAll (IT&& data)
@ -377,6 +386,7 @@ namespace lib {
return move(*this);
}
/** emplace a number of elements of the defined element type \a E */
template<typename...ARGS>
SeveralBuilder&&
fillElm (size_t cntNew, ARGS&& ...args)
@ -386,6 +396,7 @@ namespace lib {
return move(*this);
}
/** create a new content element within the managed storage */
template<class TY, typename...ARGS>
SeveralBuilder&&
emplace (ARGS&& ...args)
@ -656,6 +667,84 @@ namespace lib {
/* ===== Helpers and convenience-functions for creating SeveralBuilder ===== */
namespace allo { // Setup for custom allocator policies
template<template<typename> class ALO, typename...ARGS>
struct SetupSeveral;
template<template<typename> class ALO>
struct SetupSeveral<ALO>
{
template<class I, class E>
using Policy = AllocationPolicy<I,E,ALO>;
};
template<template<typename> class ALO, typename X>
struct SetupSeveral<ALO, ALO<X>>
{
template<class I, class E>
struct Policy
: AllocationPolicy<I,E,ALO>
{
Policy (ALO<X> refAllocator)
: AllocationPolicy<I,E,ALO>(move(refAllocator))
{ }
};
};
//
}//(End)Allocator configuration
/**
* @remarks this builder notation configures the new lib::Several container
* to perform memory management through a standard conformant allocation adapter.
* Moreover, optionally the behaviour can be configured through an extension point
* lib::allo::SetupSeveral, for which the custom allocator may provide an explicit
* template specialisation.
* @tparam ALO a C++ standard conformant allocator template, which can be instantiated
* for creating various data elements. Notably, this will be instantiated as
* `ALO<std::byte>` to create and destroy the memory buffer for content data
* @param args optional dependency wiring arguments, to be passed to the allocator
* @return a new empty SeveralBuilder, configured to use the custom allocator.
*/
template<class I, class E, class POL>
template<template<typename> class ALO, typename...ARGS>
inline auto
SeveralBuilder<I,E,POL>::withAllocator (ARGS&& ...args)
{
if (not empty())
throw err::Logic{"lib::Several builder withAllocator() must be invoked "
"prior to adding any elements to the container"};
using Setup = allo::SetupSeveral<ALO,ARGS...>;
using PolicyForAllo = typename Setup::template Policy<I,E>;
using BuilderWithAllo = SeveralBuilder<I,E,PolicyForAllo>;
return BuilderWithAllo(forward<ARGS> (args)...);
}
/*********************************************************//**
* Entrance Point: start building a lib::Several instance
* @tparam I Interface type to use for element access
* @tparam E (optional) standard element implementation type
* @return a builder instance with methods to create or copy
* data elements to populate the container...
*/
template<typename I, typename E =I>
SeveralBuilder<I,E>
makeSeveral()
{
return SeveralBuilder<I,E>{};
}
template<typename X>
SeveralBuilder<X>
makeSeveral (std::initializer_list<X> ili)
@ -665,13 +754,6 @@ namespace lib {
.appendAll (ili);
}
template<typename I, typename E =I>
SeveralBuilder<I,E>
makeSeveral()
{
return SeveralBuilder<I,E>{};
}
} // namespace lib
#endif /*LIB_SEVERAL_BUILDER_H*/

View file

@ -145,33 +145,6 @@ namespace test{
: "VAL";
}
/** helper for investigating a variadic argument pack
* @warning always spell out the template arguments explicitly
* when invoking this diagnostics, e.g. \c showVariadicTypes<ARGS...>(args...)
* otherwise the template argument matching for functions might mess up the
* kind of reference you'll see in the diagnostics.
* @see test-helper-variadic-test.cpp
*/
template<typename... EMPTY>
inline string
showVariadicTypes ()
{
return " :.";
}
template<typename X, typename... XS>
inline string
showVariadicTypes (X const& x, XS const&... xs)
{
return " :---#"
+ boost::lexical_cast<string>(1 + sizeof...(xs))
+ " -- Type: " + util::typeStr(x)
+ " " + showRefKind<X>()
+ " Address* " + boost::lexical_cast<string>(&x)
+ "\n"
+ showVariadicTypes<XS...> (xs...);
}
/**
@ -195,6 +168,8 @@ namespace test{
namespace { // helper for printing type diagnostics
template<typename X>
@ -297,6 +272,36 @@ namespace test{
}
/** helper for investigating a variadic argument pack
* @remark you can pass arguments directly to this function,
* but be sure to use `std::forward<ARGS>(args)...` when forwarding
* universal references received from a variadic argument pack \a ARG.
* @note due to reference collapsing it is not possible to distinguish receiving
* a value from receiving a rvalue-reference.
* @see test-helper-variadic-test.cpp
*/
template<typename... EMPTY>
inline string
showVariadicTypes ()
{
return " :.";
}
template<typename XX, typename... XS>
inline string
showVariadicTypes (XX&& x, XS&&... xs)
{
return " :---#"
+ util::toString (1 + sizeof...(xs))
+ " -- Type: " + showType<XX&&>()
+ " \tAdr" + util::showAddr (x)
+ "\n"
+ showVariadicTypes (std::forward<XS>(xs)...);
}
/** create a random but not insane Time value between 1s ... 10min + 500ms */

View file

@ -389,26 +389,23 @@ END
TEST "Variadic template diagnostics" TestHelperVariadic_test <<END
out-lit: --no-arg--
out-lit: :.
out-lit: --value--
out: .+#1.+ Type: double VAL Address. 0x.+
out-lit: :.
out-lit: --reference--
out: .+#1.+ Type: double REF Address. 0x.+
out: .+#1.+ Type: double& .+Adr╲.+
out-lit: :.
out-lit: --move--
out: .+#1.+ Type: double MOV Address. 0x.+
out-lit: --value--
out: .+#1.+ Type: double && .+Adr╲.+
out-lit: :.
out-lit: --two values--
out: .+#2.+ Type: char REF Address. 0x.+
out: .+#1.+ Type: long MOV Address. 0x.+
out: .+#2.+ Type: char \[4\] const& .+Adr╲.+
out: .+#1.+ Type: long && .+Adr╲.+
out-lit: :.
out-lit: --matched--
out: .+#3.+ Type: double REF Address. 0x.+
out: .+#2.+ Type: double REF Address. 0x.+
out: .+#1.+ Type: double MOV Address. 0x.+
out-lit: --references--
out: .+#3.+ Type: double& .+Adr╲.+
out: .+#2.+ Type: double const& .+Adr╲.+
out: .+#1.+ Type: double && .+Adr╲.+
out-lit: :.
out-lit: --baseclass--
out: .+#1.+ Type: Impl REF Address. 0x.+
out: .+#1.+ Type: Interface const& .+Adr╲.+
out-lit: :.
return: 0
END

View file

@ -103,20 +103,19 @@ namespace test{
run (Arg)
{
double d = makeRvalue();
double& dr = d;
double const& cr = d;
Impl obj;
Interface const& ref = obj;
cout << "--no-arg--\n" << showVariadicTypes() <<"\n";
cout << "--value--\n" << showVariadicTypes<double>(d) <<"\n";
cout << "--reference--\n" << showVariadicTypes<double&>(d) <<"\n";
cout << "--move--\n" << showVariadicTypes<double&&>(d) <<"\n";
cout << "--reference--\n" << showVariadicTypes(d) <<"\n";
cout << "--value--\n" << showVariadicTypes(makeRvalue()) <<"\n";
forwardFunction("two values", "foo", 42L); // passed as REF, MOV
forwardFunction("matched", d,dr,std::move(dr)); // passed as REF, REF, MOV
forwardFunction("two values", "foo", 42L); // displayed as char [4] const&, long &&
forwardFunction("references", d,cr,std::move(d)); // displayed as double&, double const&, double &&
forwardFunction<Interface const&>("baseclass", ref);
forwardFunction("baseclass", ref); // displayed as Interface const&
}
@ -127,10 +126,8 @@ namespace test{
void
forwardFunction (string id, ARGS&&... args)
{
// in reality here you'd invoke some factory(<std::forward<ARGS>(args)...)
//
cout << "--"<<id<<"--\n"
<< showVariadicTypes<ARGS&&...>(args...)
<< showVariadicTypes (std::forward<ARGS>(args)...)
<< "\n"
;
}

View file

@ -82970,6 +82970,17 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1718328836352" ID="ID_456408300" MODIFIED="1718328872260" TEXT="Trigger: der Standard-Allocator-Adapter von AllocationCluster">
<icon BUILTIN="info"/>
</node>
<node CREATED="1718364632147" ID="ID_1562264915" MODIFIED="1718365114321" TEXT="wird sinnvollerweise &#xfc;ber das Builder-API eingebunden">
<richcontent TYPE="NOTE"><html>
<head/>
<body>
<p>
Grunds&#228;tzlich ist der Allokator einfach durch die Belegung des 3.Template-Parameters festgelegt, das hei&#223;t, er steckt in der Policy &#8212; diese ist aber <i>rein operational bestimmt,</i>&#160;indem sie die richtigen Primitiv-Operationen mit der richtigen operationalen Semantik bereitstellt. Das ist keine gute Schnittstelle f&#252;r den praktischen Gebrauch, und deshalb wird ein Hilfs-Schema &#252;ber die Builder-Schnittstelle bereitgestellt; das erscheint eine sinnvolle Trennung zu sein, um diese zus&#228;tzliche Komplexit&#228;t aus der Kernkomponente herauszuhalten
</p>
</body>
</html></richcontent>
<arrowlink COLOR="#45627f" DESTINATION="ID_868614135" ENDARROW="Default" ENDINCLINATION="228;-16;" ID="Arrow_ID_287792352" STARTARROW="None" STARTINCLINATION="655;33;"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1718328650553" ID="ID_1053724868" MODIFIED="1718328832230" TEXT="dynamische Allokations-&#xc4;nderung einbinden">
<arrowlink COLOR="#415ab7" DESTINATION="ID_1869643772" ENDARROW="Default" ENDINCLINATION="-1433;-63;" ID="Arrow_ID_166309661" STARTARROW="None" STARTINCLINATION="1447;92;"/>
<icon BUILTIN="flag-yellow"/>
@ -83268,7 +83279,9 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1718147675355" ID="ID_1373098366" MODIFIED="1718147685899" TEXT="sinnvolle Syntax f&#xfc;r Allokator??">
<icon BUILTIN="help"/>
<node CREATED="1718150858441" ID="ID_600268938" MODIFIED="1718150918229" TEXT="makeSeveral&lt;I, E&gt;().withAllocator&lt;A&gt;()"/>
<node CREATED="1718151012651" ID="ID_868614135" MODIFIED="1718151023273" TEXT="dazu m&#xfc;&#xdf;te es eine cross-build-Methode geben">
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1718151012651" ID="ID_868614135" MODIFIED="1718365124446" TEXT="dazu m&#xfc;&#xdf;te es eine cross-build-Methode geben">
<linktarget COLOR="#45627f" DESTINATION="ID_868614135" ENDARROW="Default" ENDINCLINATION="228;-16;" ID="Arrow_ID_287792352" SOURCE="ID_1562264915" STARTARROW="None" STARTINCLINATION="655;33;"/>
<icon BUILTIN="yes"/>
<node CREATED="1718151025411" ID="ID_1523821713" MODIFIED="1718151039915" TEXT="die w&#xe4;re nur erlaubt bei (bisher) leerem Builder"/>
<node COLOR="#5b280f" CREATED="1718151047944" ID="ID_1701216144" MODIFIED="1718151087039" TEXT="(theoretisch k&#xf6;nnte man auch umkopieren, allerdings nur manchmal)">
<richcontent TYPE="NOTE"><html>
@ -83281,6 +83294,234 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</html></richcontent>
<icon BUILTIN="stop-sign"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1718365424109" ID="ID_1414527850" MODIFIED="1718365440812" TEXT="ben&#xf6;tigt: Schema zum Einrichten des Allokators">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1718365443600" ID="ID_826094679" MODIFIED="1718365447214" TEXT="Nutzmuster">
<node CREATED="1718365455761" ID="ID_1839293953" MODIFIED="1718365460053" TEXT="Typ gegeben">
<node CREATED="1718365476302" ID="ID_1390595799" MODIFIED="1718365485145" TEXT="das mu&#xdf; dann aber ein Template-Template sein"/>
<node CREATED="1718365485991" ID="ID_877770702" MODIFIED="1718365494584" TEXT="analog std::allocator&lt;TY&gt;"/>
</node>
<node CREATED="1718365857185" ID="ID_246337633" MODIFIED="1718365880668" TEXT="Verdrahtung gegeben">
<node CREATED="1718365881824" ID="ID_1834561235" MODIFIED="1718365887540" TEXT="konkrete Funktionsargumente"/>
<node CREATED="1718365902821" ID="ID_1716565217" MODIFIED="1718365913873" TEXT="aus denen der tats&#xe4;chliche Allokator konstruiert wird"/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1718367097954" ID="ID_312263866" MODIFIED="1718367155481" TEXT="das ist gef&#xe4;hrlich unbestimmt...">
<arrowlink COLOR="#f46464" DESTINATION="ID_347456374" ENDARROW="Default" ENDINCLINATION="17;-202;" ID="Arrow_ID_1949614691" STARTARROW="None" STARTINCLINATION="-58;5;"/>
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
</node>
<node CREATED="1718366709602" ID="ID_950239238" MODIFIED="1718366720317" TEXT="Verwendung der Parameter">
<icon BUILTIN="info"/>
<node CREATED="1718366725198" ID="ID_1090033382" MODIFIED="1718366738255" TEXT="die ElementFactory braucht direkt eine Alocator-Template (ALO)"/>
<node CREATED="1718366741870" ID="ID_631275185" MODIFIED="1718366789524" TEXT="sie konstruiert es per Default oder mu&#xdf; es explizit als value-Argument bekommen"/>
<node CREATED="1718366796719" ID="ID_1274231874" MODIFIED="1718366811784" TEXT="die AllocationPolicy reicht dieses Argument (und den Konstruktor) 1:1 durch"/>
<node CREATED="1718366826499" ID="ID_1767282039" MODIFIED="1718366843399" TEXT="aber die AllocationPolicy ist selber ein konfigurierbares Element">
<icon BUILTIN="messagebox_warning"/>
</node>
<node CREATED="1718366856119" ID="ID_785388847" MODIFIED="1718366879219" TEXT="der SeveralBuilder nimmt den kompletten Typ der AllocationPolicy"/>
<node CREATED="1718366892178" ID="ID_997504046" MODIFIED="1718369131234" TEXT="dieser mu&#xdf; korrekt mit den anderen Typ-Parametern I und E instantiiert worden sein"/>
</node>
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1718365914668" ID="ID_347456374" MODIFIED="1718367155482" TEXT="Problem: Inferenz">
<linktarget COLOR="#f46464" DESTINATION="ID_347456374" ENDARROW="Default" ENDINCLINATION="17;-202;" ID="Arrow_ID_1949614691" SOURCE="ID_312263866" STARTARROW="None" STARTINCLINATION="-58;5;"/>
<icon BUILTIN="messagebox_warning"/>
<node CREATED="1718366978511" ID="ID_1008148490" MODIFIED="1718367000513" TEXT="gegeben">
<node CREATED="1718367001564" ID="ID_1767676812" MODIFIED="1718367002448" TEXT="kein Typparameter + Argumente"/>
<node CREATED="1718367005499" ID="ID_1566269885" MODIFIED="1718367011745" TEXT="Typparameter + Argumente"/>
<node CREATED="1718367031824" ID="ID_1453948405" MODIFIED="1718367039713" TEXT="nur Typparameter"/>
<node CREATED="1718367040774" ID="ID_413816465" MODIFIED="1718367047081" TEXT="nur Argumente"/>
<node CREATED="1718367049094" ID="ID_1828686429" MODIFIED="1718367052576" TEXT="garnix"/>
</node>
<node CREATED="1718367203003" ID="ID_692471902" MODIFIED="1718367209415" TEXT="ben&#xf6;tigt">
<node CREATED="1718367210632" ID="ID_870120457" MODIFIED="1718367229559" TEXT="ein Template mit zwei Typargumenten"/>
<node CREATED="1718367245120" ID="ID_962348055" MODIFIED="1718367259179" TEXT="(um damit einen neuen SeveralBuilder zu instantiieren)">
<font NAME="SansSerif" SIZE="10"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1718367280430" ID="ID_666047930" MODIFIED="1718367295858" TEXT="zus&#xe4;tzlich: Erweiterungspunkt gefordert">
<icon BUILTIN="yes"/>
<node CREATED="1718367354045" ID="ID_351719166" MODIFIED="1718367379648" TEXT="um die AllocationPolicy an zuk&#xfc;nftige Allokator-Setups anzupassen"/>
<node CREATED="1718367386303" ID="ID_30749831" MODIFIED="1718367408489" TEXT="idealerweise ohne diese direkt im Header several-builder.hpp referenzieren zu m&#xfc;ssen"/>
</node>
</node>
<node CREATED="1718373522423" ID="ID_93222228" MODIFIED="1718412475211" TEXT="Definition">
<icon BUILTIN="forward"/>
<node CREATED="1718373526974" ID="ID_1686371317" MODIFIED="1718373556165" TEXT="allo::SetupSeveral&lt;ALO,ARGS...&gt;">
<node CREATED="1718373561831" ID="ID_1037391385" MODIFIED="1718408850509">
<richcontent TYPE="NODE"><html>
<head/>
<body>
<p>
enth&#228;lt ein nested template / typedef: <font face="Monospaced" color="#731212">Policy</font>
</p>
</body>
</html>
</richcontent>
<arrowlink COLOR="#fafdd6" DESTINATION="ID_23659239" ENDARROW="Default" ENDINCLINATION="-13;-151;" ID="Arrow_ID_579093827" STARTARROW="None" STARTINCLINATION="272;17;"/>
</node>
<node CREATED="1718373622001" ID="ID_641350815" MODIFIED="1718373638633" TEXT="diese wird hier abgegriffen und f&#xfc;r den SeveralBuilder verwendet"/>
</node>
<node COLOR="#5b280f" CREATED="1718373781836" ID="ID_313050395" MODIFIED="1718400886204" TEXT="Schwierigkeit: das Typ-Argument ALO">
<icon BUILTIN="button_cancel"/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1718373868841" ID="ID_1774173708" MODIFIED="1718373891295" TEXT="das ist eine zweite und kreuzweise verschachtelte Komplexit&#xe4;t">
<icon BUILTIN="messagebox_warning"/>
</node>
<node COLOR="#435e98" CREATED="1718373796218" ID="ID_567527148" MODIFIED="1718400802105" TEXT="ist es m&#xf6;glich das wegzulassen?">
<icon BUILTIN="help"/>
<node CREATED="1718373973452" ID="ID_1472130632" MODIFIED="1718374018753" TEXT="Inferenz geht normalerweise von links nach rechts"/>
<node CREATED="1718374025155" ID="ID_9268295" MODIFIED="1718400536954" TEXT="Antwort: ja &#x2014; man kann einen Default setzen"/>
</node>
<node CREATED="1718400807240" ID="ID_1984883753" MODIFIED="1718400844772" TEXT="&#x27f9; dann diese Info am Besten 1:1 in die Inferenzregel weitergeben">
<node CREATED="1718400851346" ID="ID_1439756572" MODIFIED="1718400863962" TEXT="mehrstufige Regeln sind immer komplex"/>
<node CREATED="1718400864560" ID="ID_290297248" MODIFIED="1718400877939" TEXT="und bringen selten was anderes als Probleme">
<icon BUILTIN="smiley-oh"/>
</node>
</node>
<node CREATED="1718400888786" ID="ID_1044695658" MODIFIED="1718400893126" TEXT="somit: kein Problem!"/>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1718401002675" ID="ID_594290716" MODIFIED="1718412451294" TEXT="erst mal default-Setup anfangen">
<icon BUILTIN="pencil"/>
<node CREATED="1718408497231" ID="ID_744823200" MODIFIED="1718408514033" TEXT="Bestandteile">
<node CREATED="1718408520500" ID="ID_1541328453" MODIFIED="1718408533939" TEXT="Konfigurations-Template">
<node CREATED="1718408556207" ID="ID_73442585" MODIFIED="1718408561538" TEXT="im Namespace lib::allo"/>
<node CREATED="1718408562709" ID="ID_1378291784" MODIFIED="1718408594322">
<richcontent TYPE="NODE"><html>
<head/>
<body>
<p>
Name: <font face="Monospaced" color="#7d0d27">SetupSeveral</font>
</p>
</body>
</html>
</richcontent>
<node CREATED="1718408597002" ID="ID_1822635550" MODIFIED="1718408607465" TEXT="das deutet eine Namenskonvention an"/>
</node>
<node CREATED="1718408613255" ID="ID_1638086547" MODIFIED="1718408666260" TEXT="idealerweise ohne direkte Abh&#xe4;ngikeit zu several-builder.hpp ">
<node CREATED="1718408669600" ID="ID_689580443" MODIFIED="1718408688673" TEXT="da sonst Header-Includes verschleppt werden"/>
<node CREATED="1718408689405" ID="ID_487913454" MODIFIED="1718408698695" TEXT="oder man eine Include-Reihenfolge beachten mu&#xdf;"/>
<node CREATED="1718408700476" ID="ID_171864133" MODIFIED="1718408720948" TEXT="beides ist Sch***e">
<icon BUILTIN="smiley-angry"/>
</node>
</node>
</node>
<node CREATED="1718408535690" ID="ID_1653544039" MODIFIED="1718408542166" TEXT="enth&#xe4;lt nested Template">
<node CREATED="1718373561831" ID="ID_23659239" MODIFIED="1718408850509">
<richcontent TYPE="NODE"><html>
<head/>
<body>
<p>
Schema: <font color="#731212" face="Monospaced">Policy&lt;I,E&gt;</font>
</p>
</body>
</html>
</richcontent>
<linktarget COLOR="#fafdd6" DESTINATION="ID_23659239" ENDARROW="Default" ENDINCLINATION="-13;-151;" ID="Arrow_ID_579093827" SOURCE="ID_1037391385" STARTARROW="None" STARTINCLINATION="272;17;"/>
</node>
<node CREATED="1718408890347" ID="ID_62564360" MODIFIED="1718408897333" TEXT="dieses wird instantiiert..."/>
<node CREATED="1718408897993" ID="ID_723687381" MODIFIED="1718408917652" TEXT="und dann in den neuen SeveralBuilder eingef&#xfc;hrt"/>
</node>
</node>
<node CREATED="1718408946211" ID="ID_1690080817" MODIFIED="1718408948798" TEXT="Einrichtung">
<node CREATED="1718408950546" ID="ID_1035953340" MODIFIED="1718408966828" TEXT="ggfs. m&#xfc;ssen Argumente durchgereicht werden">
<node CREATED="1718408970351" ID="ID_899929705" MODIFIED="1718409010496" TEXT="aber die ElementFactory erwartet konkret ALO&lt;byte&gt;">
<icon BUILTIN="messagebox_warning"/>
</node>
<node CREATED="1718409011842" ID="ID_1034945090" MODIFIED="1718409044490" TEXT="L&#xf6;sung: die jeweilige Policy konstruiert ALO&lt;byte&gt;"/>
</node>
<node CREATED="1718409046909" ID="ID_1450348533" MODIFIED="1718409076997" TEXT="idealerweise: unabh&#xe4;ngig von several-builder.hpp deklarierbar">
<node CREATED="1718409093743" ID="ID_312050551" MODIFIED="1718409198652" TEXT="Grund: weil man dann die Spezialisierung beim Allocator definieren kann">
<richcontent TYPE="NOTE"><html>
<head/>
<body>
<p>
Denn auch den Allocator verwendet man typischerweise an vielen Stellen, und nicht &#252;berall m&#246;chte man dann auch several-builder.hpp mit reinziehen; w&#228;re also gut wenn es einfacher Template-Code ist, der mit entspr. Forward-Deklarationen auch &#187;blank&#171; vom Compiler akzeptiert wird
</p>
</body>
</html>
</richcontent>
</node>
<node CREATED="1718409079204" ID="ID_1662416508" MODIFIED="1718409204382" TEXT="erst zur Instantiierung m&#xfc;ssen beide Header da sein">
<icon BUILTIN="idea"/>
</node>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1718412437319" ID="ID_947832201" MODIFIED="1718412481457" TEXT="dann Spezialisierung f&#xfc;r AllocationCluster">
<icon BUILTIN="pencil"/>
<node CREATED="1718412486764" ID="ID_1577108455" MODIFIED="1718412502863" TEXT="Vorbereitung: Forward-Deklarationen">
<node CREATED="1718412503850" ID="ID_1754798061" MODIFIED="1718412512686" TEXT="in lib/allocation-cluster.hpp"/>
<node CREATED="1718412516780" ID="ID_1342390871" MODIFIED="1718412531679" TEXT="anonymer Namespace">
<node CREATED="1718412549972" ID="ID_1508822168" MODIFIED="1718412562431">
<richcontent TYPE="NODE"><html>
<head/>
<body>
<p>
<font face="Monospaced" size="2">template&lt;class I, class E, template&lt;typename&gt; class ALO&gt; </font>
</p>
<p>
<font face="Monospaced" size="2">struct AllocationPolicy;</font>
</p>
</body>
</html>
</richcontent>
</node>
</node>
<node CREATED="1718412568076" ID="ID_587369018" MODIFIED="1718412572323" TEXT="namespace allo">
<node CREATED="1718412581956" ID="ID_25423604" MODIFIED="1718412596025">
<richcontent TYPE="NODE"><html>
<head/>
<body>
<p>
<font face="Monospaced" size="2">template&lt;template&lt;typename&gt; class ALO, typename...ARGS&gt; </font>
</p>
<p>
<font face="Monospaced" size="2">struct SetupSeveral;</font>
</p>
</body>
</html>
</richcontent>
</node>
</node>
</node>
<node CREATED="1718412601887" ID="ID_683537525" MODIFIED="1718412620189" TEXT="Spezialisierung...">
<node CREATED="1718412621239" ID="ID_1341703757" MODIFIED="1718412637565">
<richcontent TYPE="NODE"><html>
<head/>
<body>
<p>
<font face="Monospaced" size="2" color="#760a3a">SetupSeveral&lt;std::void_t, lib::AllocationCluster&amp;&gt;</font>
</p>
</body>
</html>
</richcontent>
</node>
<node CREATED="1718412642779" ID="ID_234744249" MODIFIED="1718412795303" TEXT="Builder wird nur mit einer Referenz auf einen aktuellen AllocationCluster aufgerufen">
<richcontent TYPE="NOTE"><html>
<head/>
<body>
<p>
Die Definition der Builder-Methode <font color="#5d158e" face="Monospaced">withAllocator&lt;ALO&gt;(args...)</font>&#160; sollte dazu f&#252;hren, da&#223; das Konfigurations-Template <font color="#ac1212" face="Monospaced"><b>SetupSeveral</b></font>&#160; genau mit diesen Argumenten instantiiert wird...
</p>
</body>
</html>
</richcontent>
</node>
<node CREATED="1718412831442" ID="ID_155484703" MODIFIED="1718412860303" TEXT="definiere hier diese Policy als ein class-Template, das von AllocationPolicy erbt"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1718412861728" ID="ID_13977121" MODIFIED="1718412883443" TEXT="damit ist der Rahmen geschaffen, um die realloc()-Funktion zu adaptieren">
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node COLOR="#581b6b" CREATED="1718412892447" ID="ID_1556718828" MODIFIED="1718412987645" TEXT="ob das man gutgeht....">
<font ITALIC="true" NAME="SansSerif" SIZE="11"/>
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#2c878c" CREATED="1718412901000" ID="ID_1589785077" MODIFIED="1718412970228" TEXT="YESS!!! der Compiler fri&#xdf;t das">
<icon BUILTIN="ksmiletris"/>
</node>
</node>
</node>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1718368775878" ID="ID_1921994351" LINK="#ID_28139752" MODIFIED="1718368785941" TEXT="testen">
<icon BUILTIN="flag-yellow"/>
</node>
</node>
</node>
@ -83704,6 +83945,28 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1716857382442" ID="ID_28139752" MODIFIED="1716857402101" TEXT="check_CustomAllocator">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1718368791047" ID="ID_59759193" MODIFIED="1718368826816" TEXT="direktes construct-and-embed mit AllocationCluster demonstrieren">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1718368831343" ID="ID_1248831538" LINK="#ID_1419157708" MODIFIED="1718368953078">
<richcontent TYPE="NODE"><html>
<head/>
<body>
<p>
braucht ein API zum <i>&#220;bernehmen </i>eines bereits konstruierten Objekts
</p>
</body>
</html>
</richcontent>
<richcontent TYPE="NOTE"><html>
<head/>
<body>
<p>
zun&#228;chst hatte ich AllocationCluster daf&#252;r definiert, da&#223; die Objekte <i>direkt im Cluster-Speicher erzeugt </i>werden; hier aber liegt ein valider Fall vor, in dem das Objekt bereits erzeugt wurde (n&#228;mlich &#252;ber den Builder), und von dort per move/copy in den Cluster &#252;bernommen werden soll
</p>
</body>
</html></richcontent>
</node>
</node>
</node>
</node>
</node>
@ -83977,6 +84240,8 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1715727225764" ID="ID_123722889" MODIFIED="1715727230671" TEXT="getAllocator&lt;TY&gt;"/>
<node CREATED="1715727232648" ID="ID_597499360" MODIFIED="1715727238366" TEXT="create"/>
<node CREATED="1716848614943" ID="ID_1316151534" MODIFIED="1716848618330" TEXT="createDisposable"/>
<node CREATED="1718368600814" ID="ID_1688514818" MODIFIED="1718368708563" TEXT="embed"/>
<node CREATED="1718368606877" ID="ID_1419157708" MODIFIED="1718368714204" TEXT="embedDisposable"/>
<node CREATED="1715728180516" ID="ID_412948320" MODIFIED="1715728191170" TEXT="allot&lt;TY&gt;(cnt)"/>
<node CREATED="1715727255639" ID="ID_1782845675" MODIFIED="1715727439713" TEXT="allotMemory(size_t)"/>
<node CREATED="1715727250709" ID="ID_886757416" MODIFIED="1716848629262" TEXT="numExtents"/>
@ -84344,8 +84609,7 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
Und zwar weil sich aus der konkreten Implementierung diese M&#246;glichkeit einfach ergibt
</p>
</body>
</html>
</richcontent>
</html></richcontent>
</node>
<node COLOR="#435e98" CREATED="1718320726218" ID="ID_1869643772" MODIFIED="1718328832230" TEXT="wird im Besonderen von lib::Several &#xfc;ber einen dedizierte Policy genutzt">
<linktarget COLOR="#415ab7" DESTINATION="ID_1869643772" ENDARROW="Default" ENDINCLINATION="-1433;-63;" ID="Arrow_ID_166309661" SOURCE="ID_1053724868" STARTARROW="None" STARTINCLINATION="1447;92;"/>