diff --git a/research/try.cpp b/research/try.cpp index dbad5c04a..5948b8bec 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -41,7 +41,11 @@ /** @file try.cpp - * Investigation: static initialisation order -- especially of static template member fields + * Investigation: static initialisation order -- especially of static template member fields. + * This version embeds the factory as Meyer's Singleton into the Front-Template using it, and + * it invokes the factory from within the Front constructor -- thereby ensuring the factory + * is indeed initialised prior to any usage and its lifespan extends beyond the lifespan of the + * last instance using it. */ typedef unsigned int uint; @@ -76,25 +80,31 @@ template class Front { public: - static Factory fac; + Factory& + fac() + { + static Factory fac; + return fac; + } + Front() { - cout << "Front-ctor val="<::instance = &newInstance; - Depend::factory.disable(); + Depend::factory().disable(); } static void @@ -457,7 +457,7 @@ namespace lib { { Lock guard; Depend::instance = nullptr; - Depend::factory.disable(); + Depend::factory().disable(); } }; diff --git a/src/lib/depend.hpp b/src/lib/depend.hpp index 9e44a1d8a..3dff59462 100644 --- a/src/lib/depend.hpp +++ b/src/lib/depend.hpp @@ -78,6 +78,20 @@ ** than the comparable unprotected direct access without lazy initialisation. ** This is orders of magnitude better than any flavour of conventional locking. ** + ** ### Initialisation of the shared factory + ** + ** We package the creation and destruction functors for the object to be managed + ** into a factory, which is shared per type. Such a shared factory could live within + ** a static member field `Depend::factory` -- however, the _definition_ of such + ** a templated static member happens on first use of the enclosing template _instance_, + ** and it seems the _initialisation order_ of such fields is not guaranteed, especially + ** when used prior to main, from static initialisation code. For that reason, we manage + ** the _factory_ as Meyer's singleton, so it can be accessed independently from the + ** actual target object's lifecycle and the compiler will ensure initialisation + ** prior to first use. To ensure the lifespan of this embedded factory object + ** extends beyond the last instance of `lib::Depend`, we also need to + ** access that factory from a ctor + ** ** @see depend-inject.hpp ** @see lib::DependInject ** @see Singleton_test @@ -137,7 +151,7 @@ namespace lib { } OBJ* - operator() () + buildTarget() { return creator_? creator_() : buildAndManage(); @@ -278,9 +292,15 @@ namespace lib { using Factory = DependencyFactory; using Lock = ClassLock; - /* === shared per type === */ + /** shared per type */ static Instance instance; - static Factory factory; + + static Factory& + factory() ///< Meyer's Singleton to ensure initialisation on first use + { + static Factory sharedFactory; + return sharedFactory; + } friend class DependInject; @@ -298,15 +318,15 @@ namespace lib { SRV* object = instance.load (std::memory_order_acquire); if (!object) { - factory.zombieCheck(); + factory().zombieCheck(); Lock guard; object = instance.load (std::memory_order_relaxed); if (!object) { - object = factory(); - factory.disable(); - factory.atDestruction([]{ instance = nullptr; }); + object = factory().buildTarget(); + factory().disable(); + factory().atDestruction([]{ instance = nullptr; }); } instance.store (object, std::memory_order_release); } @@ -324,6 +344,14 @@ namespace lib { { return instance.load (std::memory_order_acquire); } + + /** @remark this ctor ensures the factory is created prior to first use, + * and stays alive during the whole lifespan of any `Depend` + */ + Depend() + { + factory().zombieCheck(); + } }; @@ -333,9 +361,6 @@ namespace lib { template std::atomic Depend::instance; - template - DependencyFactory Depend::factory; - } // namespace lib diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index f4dc5e2d4..9bbbabec2 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -351,7 +351,7 @@ - + @@ -405,7 +405,7 @@ - + @@ -626,7 +626,7 @@ - + @@ -867,10 +867,10 @@ - + - + @@ -999,16 +999,16 @@ - - + + - + - + @@ -1025,7 +1025,7 @@ - + @@ -1051,12 +1051,12 @@ - + - + @@ -1336,7 +1336,7 @@ - + @@ -1369,7 +1369,7 @@ - + @@ -1410,11 +1410,11 @@ - - + + - + @@ -1429,19 +1429,19 @@ - + - + - + @@ -1451,7 +1451,7 @@ - + @@ -1705,7 +1705,7 @@ - + @@ -1715,7 +1715,7 @@ - + @@ -1730,12 +1730,12 @@ - + - + @@ -2037,7 +2037,7 @@ - + @@ -3612,7 +3612,7 @@ - + @@ -3936,7 +3936,7 @@ - + @@ -3992,13 +3992,13 @@ - + - + @@ -4032,8 +4032,8 @@ - - + + @@ -4051,7 +4051,7 @@ - + @@ -4059,7 +4059,7 @@ - + @@ -4074,12 +4074,12 @@ - + - + @@ -4087,13 +4087,13 @@ - + - + @@ -4181,7 +4181,7 @@ - + @@ -4201,9 +4201,9 @@ - + - + @@ -4212,26 +4212,26 @@ - + - + - + - + - + @@ -4323,7 +4323,7 @@ - + @@ -4601,7 +4601,7 @@ - + @@ -4686,7 +4686,7 @@ - + @@ -4707,7 +4707,7 @@ - + @@ -4725,13 +4725,13 @@ - + - + @@ -4748,26 +4748,26 @@ - + - + - + - + - + - + @@ -4775,32 +4775,32 @@ - + - + - + - + - + - + - + @@ -4834,29 +4834,29 @@ - + - + - + - + - + - + @@ -4870,7 +4870,7 @@ - + @@ -4898,7 +4898,7 @@ - + @@ -4913,24 +4913,24 @@ - + - + - + - - + + - + @@ -4947,19 +4947,19 @@ - + - + - + @@ -4980,17 +4980,17 @@ - + - + - + @@ -5039,7 +5039,7 @@ - + @@ -5125,7 +5125,7 @@ - + @@ -5140,17 +5140,17 @@ - + - + - + @@ -5167,23 +5167,23 @@ - + - + - + - + @@ -5199,14 +5199,14 @@ - + - + - + @@ -5223,13 +5223,13 @@ - + - + @@ -5294,14 +5294,14 @@ - + - + @@ -5310,9 +5310,9 @@ - + - + @@ -5321,9 +5321,9 @@ - + - + @@ -5363,35 +5363,35 @@ - + - + - + - + - + - + - + @@ -5421,10 +5421,10 @@ - + - + @@ -5434,14 +5434,14 @@ - + - + @@ -5566,7 +5566,7 @@ - + @@ -5597,10 +5597,10 @@ - + - + @@ -5608,18 +5608,18 @@ - + - + - + - + @@ -5652,7 +5652,7 @@ - + @@ -5682,9 +5682,9 @@ - + - + @@ -5738,7 +5738,7 @@ - + @@ -5943,7 +5943,7 @@ - + @@ -5961,21 +5961,21 @@ - + - + - + - + @@ -5983,7 +5983,7 @@ - + @@ -5994,7 +5994,7 @@ - + @@ -6006,7 +6006,7 @@ - + @@ -6014,7 +6014,7 @@ - + @@ -6032,7 +6032,7 @@ - + @@ -6048,7 +6048,7 @@ - + @@ -6061,7 +6061,7 @@ - + @@ -6083,7 +6083,7 @@ - + @@ -6108,7 +6108,7 @@ - + @@ -6133,9 +6133,9 @@ - + - + @@ -6148,7 +6148,7 @@ - + @@ -6161,7 +6161,7 @@ - + @@ -6292,7 +6292,7 @@ - + @@ -6341,7 +6341,7 @@ - + @@ -6452,24 +6452,24 @@ - + - + - + - + - + @@ -6491,19 +6491,19 @@ - + - + - + @@ -6512,7 +6512,7 @@ - + @@ -6547,7 +6547,7 @@ - + @@ -6571,12 +6571,12 @@ - + - + @@ -6597,7 +6597,7 @@ - + @@ -6605,7 +6605,7 @@ - + @@ -6619,9 +6619,9 @@ - + - + @@ -6629,12 +6629,12 @@ - + - + @@ -6643,7 +6643,7 @@ - + @@ -6707,7 +6707,7 @@ - + @@ -6744,9 +6744,9 @@ - + - + @@ -6862,7 +6862,7 @@ - + @@ -6881,7 +6881,7 @@ - + @@ -6920,12 +6920,12 @@ - + - + @@ -6939,7 +6939,7 @@

- + @@ -6981,7 +6981,7 @@ - + @@ -6990,14 +6990,14 @@ - + - + - + @@ -7013,10 +7013,10 @@ - + - + @@ -7031,12 +7031,12 @@ - + - + @@ -7055,7 +7055,7 @@ - + @@ -7073,7 +7073,7 @@ - + @@ -7146,7 +7146,7 @@ - + @@ -7166,7 +7166,7 @@ - + @@ -7194,7 +7194,7 @@ - + @@ -7202,7 +7202,7 @@ - + @@ -7228,7 +7228,7 @@ - + @@ -7306,7 +7306,7 @@ - + @@ -7318,7 +7318,7 @@ - + @@ -7327,7 +7327,7 @@ - + @@ -7341,10 +7341,10 @@ - + - + @@ -7352,9 +7352,9 @@ - + - + @@ -7362,7 +7362,7 @@ - + @@ -7370,7 +7370,7 @@ - + @@ -7378,7 +7378,7 @@ - + @@ -7387,7 +7387,7 @@ - + @@ -7405,15 +7405,15 @@ - + - + - + @@ -7423,7 +7423,7 @@ - + @@ -7440,7 +7440,7 @@
- + @@ -7450,12 +7450,12 @@ - + - + @@ -7476,20 +7476,20 @@ - + - + - + @@ -7498,7 +7498,7 @@ - + @@ -7509,7 +7509,7 @@ - + @@ -7550,7 +7550,7 @@ - + @@ -7561,7 +7561,7 @@ - + @@ -7570,7 +7570,7 @@ - + @@ -7581,7 +7581,7 @@ - + @@ -7591,13 +7591,13 @@ - + - + @@ -7844,7 +7844,7 @@ - + @@ -7855,38 +7855,38 @@ - + - + - + - + - + - + - + @@ -7899,7 +7899,7 @@ - + @@ -7932,13 +7932,13 @@ - + - + @@ -7965,11 +7965,11 @@ - + - + @@ -7980,11 +7980,11 @@ - + - + @@ -7996,24 +7996,24 @@ - + - + - + - + - + @@ -8027,7 +8027,7 @@ - + @@ -8059,10 +8059,10 @@ - + - + @@ -8070,7 +8070,7 @@ - + @@ -8119,7 +8119,7 @@ - + @@ -8133,7 +8133,7 @@ - + @@ -8161,7 +8161,7 @@ - + @@ -8176,7 +8176,7 @@ - + @@ -8205,7 +8205,7 @@ - + @@ -8224,12 +8224,12 @@

- + - + @@ -8260,18 +8260,18 @@ - + - + - + - + @@ -8303,7 +8303,7 @@ - + @@ -8324,7 +8324,7 @@ - + @@ -8345,7 +8345,7 @@ - + @@ -8354,20 +8354,20 @@ - + - + - + - + @@ -8382,7 +8382,7 @@ - + @@ -8400,7 +8400,7 @@ - + @@ -8408,10 +8408,10 @@ - + - + @@ -8432,7 +8432,7 @@
- + @@ -8441,7 +8441,7 @@ - + @@ -8469,7 +8469,7 @@ - + @@ -8482,10 +8482,10 @@ - + - + @@ -8497,7 +8497,7 @@ - + @@ -8507,23 +8507,23 @@ - + - + - + - + - + - + @@ -8540,7 +8540,7 @@ - + @@ -8564,7 +8564,7 @@ - + @@ -8579,8 +8579,8 @@
- - + + @@ -8588,12 +8588,12 @@ - + - + @@ -8604,13 +8604,13 @@ - + - + @@ -8659,7 +8659,7 @@ - + @@ -8667,7 +8667,7 @@ - + @@ -8687,15 +8687,15 @@ - + - + - + @@ -8719,7 +8719,7 @@ - + @@ -8730,7 +8730,7 @@ - + @@ -8743,7 +8743,7 @@ - + @@ -8751,7 +8751,7 @@ - + @@ -8765,7 +8765,7 @@ - + @@ -8774,14 +8774,14 @@ - + - + - + @@ -8795,7 +8795,7 @@ - + @@ -8810,7 +8810,7 @@ - + @@ -8836,7 +8836,7 @@ - + @@ -8855,7 +8855,7 @@ - + @@ -8871,7 +8871,7 @@ - + @@ -8897,7 +8897,7 @@ - + @@ -8910,7 +8910,7 @@ - + @@ -8936,11 +8936,11 @@ - + - + @@ -8949,7 +8949,7 @@ - + @@ -8958,7 +8958,7 @@ - + @@ -8980,7 +8980,7 @@ - + @@ -9001,9 +9001,9 @@ - + - + @@ -9042,7 +9042,7 @@ - + @@ -9060,7 +9060,7 @@ - + @@ -9111,7 +9111,7 @@ - + @@ -9125,7 +9125,7 @@ - + @@ -9146,7 +9146,7 @@ - + @@ -9252,7 +9252,7 @@ - + @@ -9359,8 +9359,7 @@ Grundsätzlich gilt hier die Einschätzung: Klarheit der Schnittstelle hat Vorrang

- - +
@@ -9414,7 +9413,7 @@ - + @@ -9425,25 +9424,25 @@ - + - + - + - + @@ -9466,25 +9465,25 @@ - + - + - - + + - + - + @@ -9515,14 +9514,14 @@ - + - + @@ -9565,16 +9564,16 @@ - + - + - + @@ -9634,9 +9633,9 @@ - + - + @@ -9644,12 +9643,12 @@ - + - + @@ -9664,12 +9663,12 @@ - + - + @@ -9677,7 +9676,7 @@ - + @@ -9733,7 +9732,7 @@ - + @@ -9806,13 +9805,13 @@ - + - + @@ -9909,7 +9908,7 @@ - + @@ -9919,7 +9918,7 @@ - + @@ -9951,21 +9950,21 @@ - + - - + + - + - + - - - + + + @@ -9986,19 +9985,19 @@ - + - - + + - + @@ -10021,7 +10020,7 @@ - + @@ -10035,21 +10034,21 @@ - + - + - + - + - + @@ -10057,9 +10056,9 @@ - + - + @@ -10099,7 +10098,7 @@ - + @@ -10130,7 +10129,7 @@ - + @@ -10146,14 +10145,14 @@ - + - - + + @@ -10161,7 +10160,7 @@ - + @@ -10225,9 +10224,9 @@ - + - + @@ -10243,7 +10242,7 @@ - + @@ -10265,11 +10264,11 @@ - - + + - + @@ -10277,10 +10276,10 @@ - + - + @@ -10301,12 +10300,12 @@ - + - + @@ -10316,13 +10315,13 @@ - + - + - + - + @@ -10338,9 +10337,9 @@ - + - + @@ -10349,13 +10348,13 @@ - + - + @@ -10363,7 +10362,7 @@ - + @@ -10378,7 +10377,7 @@ - + @@ -10414,7 +10413,7 @@ - + @@ -10449,7 +10448,7 @@ - + @@ -10464,7 +10463,7 @@ - + @@ -10517,9 +10516,9 @@ - + - + @@ -10527,7 +10526,7 @@ - + @@ -10540,7 +10539,7 @@ - + @@ -10579,11 +10578,11 @@ - + - + - + @@ -10594,12 +10593,12 @@ - + - + @@ -10608,7 +10607,7 @@ - + @@ -10617,7 +10616,7 @@ - + @@ -10630,14 +10629,14 @@ - + - + @@ -10660,7 +10659,7 @@ - + @@ -10669,12 +10668,12 @@ - + - + @@ -10687,7 +10686,7 @@ - + @@ -10697,7 +10696,7 @@ - + @@ -10734,7 +10733,7 @@ - + @@ -10755,15 +10754,15 @@ - + - + - + @@ -10801,21 +10800,21 @@ - + - + - + - + @@ -10851,37 +10850,37 @@ - + - + - + - - - + + + - + - - - + + + - - + + - + @@ -10891,9 +10890,9 @@ - + - + @@ -10912,7 +10911,7 @@ - + @@ -10934,7 +10933,7 @@ - + @@ -10943,9 +10942,9 @@ - + - + @@ -10960,18 +10959,18 @@ - + - - - + + + - + @@ -10982,13 +10981,13 @@ - + - + @@ -10997,14 +10996,14 @@ - + - + @@ -11014,7 +11013,7 @@ - + @@ -11055,13 +11054,13 @@ - + - + - + @@ -11081,14 +11080,14 @@ - + - + @@ -11097,11 +11096,11 @@ - + - + @@ -11141,12 +11140,12 @@ - + - + @@ -11194,8 +11193,7 @@ klassischer Fall von »premature optimisation«

- -
+
@@ -11237,13 +11235,13 @@ - + - + @@ -11271,14 +11269,14 @@ - + - + - + @@ -11292,7 +11290,7 @@ - + @@ -11302,7 +11300,7 @@ - + @@ -11324,12 +11322,12 @@ - + - + @@ -11390,7 +11388,7 @@ - + @@ -11398,7 +11396,7 @@ - + @@ -11536,7 +11534,7 @@ - + @@ -11617,8 +11615,8 @@ - - + + @@ -11650,7 +11648,7 @@ - + @@ -11682,7 +11680,7 @@ - + @@ -11752,12 +11750,12 @@ - + - + @@ -11779,12 +11777,12 @@ - + - + @@ -11809,7 +11807,7 @@ - + @@ -11836,7 +11834,7 @@ - + @@ -11865,7 +11863,7 @@ - + @@ -12133,8 +12131,7 @@ warum ViewLocator so nebulös bleibt: es gibt noch kein Lumiera GUI

- -
+
@@ -12183,8 +12180,7 @@ ist in unserem Test-Framework nicht realisierbar

- - + @@ -12203,8 +12199,7 @@ Policy: Unit-Tests dürfen keine GTK-Abhängigkeit haben

- - +
@@ -12381,13 +12376,13 @@ - + - + @@ -12399,7 +12394,7 @@ - + @@ -12408,7 +12403,7 @@ - + @@ -12430,19 +12425,19 @@ - + - + - + - + @@ -12671,7 +12666,7 @@ - + @@ -12702,7 +12697,7 @@ - + @@ -12714,7 +12709,7 @@ - + @@ -12739,12 +12734,12 @@ - + - + @@ -12753,7 +12748,7 @@ - + @@ -12825,8 +12820,7 @@ Schicht unter dem ViewLocator

- -
+
@@ -12856,7 +12850,7 @@ - + @@ -12877,8 +12871,7 @@ aber es könnte durchaus sein, daß man auf sie generisch zugreifen möchte

- -
+
@@ -12899,7 +12892,7 @@ - + @@ -12935,8 +12928,7 @@ In Fall-1 wird man eine bool-Abfrage machen wollen, und man kann auch mit einer false-Antwort umgehen. In Fall-2 dagegen bleibt nur noch der Tod. Und davon ist im Regelfall nicht auszugehen. Im Moment sehe ich Fall-2 als den standard-use-Case

- - +
@@ -12953,8 +12945,7 @@ - - + @@ -12986,7 +12977,7 @@
- + @@ -13007,8 +12998,7 @@ Die einzig interessante Information ist, ob es gelungen ist

- -
+
@@ -13038,8 +13028,7 @@ aber genau das ist hier jeweils nur in einem Fall gegeben

- - +
@@ -13076,7 +13065,7 @@ - + @@ -13126,7 +13115,7 @@ - + @@ -15501,8 +15490,7 @@ (GlobalCtx)->InteractionDirector (=Model Root)

- - +
@@ -15523,8 +15511,7 @@ (GlobalCtx)->InteractionDirector->Navigator

- - + @@ -15568,8 +15555,7 @@ (GlobalCtx)->InteractionDirector->ViewLocator

- - + @@ -15583,8 +15569,7 @@ (GlobalCtx)->WindowLocator->UIComponentAccessor

- - + @@ -15595,7 +15580,7 @@ - + @@ -15620,13 +15605,12 @@ erfordert bereits Kenntnis der Innereien

- - +
- + @@ -15636,12 +15620,11 @@ (GlobalCtx)->WindowLocator

- -
+ - + @@ -15651,8 +15634,7 @@ (GlobalCtx)->WindowLocator->PanelLocator

- -
+ @@ -16117,7 +16099,7 @@ - + @@ -16143,7 +16125,7 @@ - + @@ -16211,7 +16193,7 @@ - + @@ -16267,7 +16249,7 @@ - + @@ -16345,7 +16327,7 @@ - + @@ -16371,7 +16353,7 @@ - + @@ -16404,7 +16386,7 @@ - + @@ -16429,7 +16411,7 @@ - + @@ -16442,7 +16424,7 @@ - + @@ -16539,7 +16521,7 @@ - + @@ -16612,7 +16594,7 @@ - + @@ -16981,7 +16963,7 @@ - + @@ -17072,7 +17054,7 @@ - + @@ -17150,7 +17132,7 @@ - + @@ -17185,7 +17167,7 @@ - + @@ -17274,13 +17256,13 @@ - + - + - + @@ -17297,8 +17279,8 @@ - - + + @@ -17390,12 +17372,12 @@ - - + + - + @@ -17489,7 +17471,7 @@ - + @@ -17526,9 +17508,9 @@ - + - + @@ -17714,7 +17696,7 @@ - + @@ -17755,7 +17737,7 @@ - + @@ -17809,7 +17791,7 @@ - + @@ -17879,7 +17861,7 @@ - + @@ -17987,7 +17969,7 @@ - + @@ -18085,12 +18067,12 @@ - + - + @@ -18142,7 +18124,7 @@ - + @@ -18153,7 +18135,7 @@ - + @@ -18165,7 +18147,7 @@ - + @@ -18202,7 +18184,7 @@ - + @@ -18261,7 +18243,7 @@ - + @@ -18538,7 +18520,7 @@ - + @@ -18600,7 +18582,7 @@ - + @@ -18678,7 +18660,7 @@ - + @@ -18697,7 +18679,7 @@ - + @@ -18732,7 +18714,7 @@ - + @@ -18836,7 +18818,7 @@ - + @@ -18865,7 +18847,7 @@ - + @@ -18948,7 +18930,7 @@ - + @@ -19054,11 +19036,11 @@ - + - + @@ -19066,11 +19048,11 @@ - + - + @@ -19078,18 +19060,18 @@ - + - + - + @@ -19110,21 +19092,21 @@ - + - + - + @@ -19174,13 +19156,13 @@ - + - + - + @@ -19229,22 +19211,22 @@ - + - + - + - + @@ -19259,7 +19241,7 @@ - + @@ -19328,7 +19310,7 @@ - + @@ -19343,14 +19325,14 @@ - + - + @@ -19370,7 +19352,7 @@ - + @@ -19382,7 +19364,7 @@ - + @@ -19429,7 +19411,7 @@ - + @@ -19450,7 +19432,7 @@ - + @@ -19468,13 +19450,13 @@ - - + + - + @@ -19527,7 +19509,7 @@ - + @@ -19574,7 +19556,7 @@ - + @@ -19596,14 +19578,14 @@ - + - + @@ -19663,7 +19645,7 @@ - + @@ -19812,7 +19794,7 @@ - + @@ -19930,23 +19912,23 @@ - + - + - + - + - + - - + + @@ -19988,7 +19970,7 @@ - + @@ -20044,7 +20026,7 @@ - + @@ -20092,7 +20074,7 @@ - + @@ -20324,14 +20306,14 @@ - + - + @@ -20341,7 +20323,7 @@ - + @@ -20353,18 +20335,18 @@ - + - + - + - + @@ -20401,7 +20383,7 @@ - + @@ -20425,7 +20407,7 @@ - + @@ -20448,7 +20430,7 @@ - + @@ -20466,13 +20448,13 @@ - + - + @@ -20519,7 +20501,7 @@ - + @@ -20566,7 +20548,7 @@ - + @@ -20578,24 +20560,24 @@ - + - + - + - + - + @@ -20636,7 +20618,7 @@ - + @@ -20659,7 +20641,7 @@ - + @@ -20718,7 +20700,7 @@ - + @@ -20763,7 +20745,7 @@ - + @@ -21218,7 +21200,7 @@ - + @@ -21351,7 +21333,7 @@ - + @@ -21365,7 +21347,7 @@ - + @@ -21430,14 +21412,14 @@ - + - + - + @@ -21455,7 +21437,7 @@ - + @@ -21536,7 +21518,7 @@ - + @@ -21685,7 +21667,7 @@ - + @@ -22397,7 +22379,7 @@ - + @@ -22814,7 +22796,7 @@ - + @@ -22917,7 +22899,7 @@ - + @@ -23224,7 +23206,7 @@ - + @@ -23400,7 +23382,7 @@ - + @@ -23568,7 +23550,7 @@ - + @@ -23767,7 +23749,7 @@ - + @@ -23978,7 +23960,7 @@ - + @@ -24116,7 +24098,7 @@ - + @@ -24130,7 +24112,7 @@ - + @@ -24147,7 +24129,7 @@ - + @@ -24169,7 +24151,7 @@ - + @@ -24247,7 +24229,7 @@ - + @@ -24445,7 +24427,7 @@ - + @@ -24554,7 +24536,7 @@ - + @@ -24604,7 +24586,7 @@ - + @@ -24683,7 +24665,7 @@ - + @@ -24740,7 +24722,7 @@ - + @@ -24792,7 +24774,7 @@ - + @@ -24963,7 +24945,7 @@ - + @@ -24984,7 +24966,7 @@ - + @@ -25039,7 +25021,7 @@ - + @@ -25218,12 +25200,12 @@ - + - + @@ -25322,7 +25304,7 @@ - + @@ -25369,7 +25351,7 @@ - + @@ -25469,7 +25451,7 @@ - + @@ -25601,7 +25583,7 @@ - + @@ -25806,7 +25788,7 @@ - + @@ -26001,7 +25983,7 @@ - + @@ -26169,7 +26151,7 @@ - + @@ -26188,7 +26170,7 @@ - + @@ -26217,14 +26199,14 @@ - + - + @@ -26232,7 +26214,7 @@ - + @@ -26255,7 +26237,7 @@ - + @@ -26310,7 +26292,7 @@ - + @@ -26345,10 +26327,10 @@ - + - + @@ -26588,7 +26570,7 @@ - + @@ -26692,7 +26674,7 @@ - + @@ -26841,7 +26823,7 @@ - + @@ -26875,7 +26857,7 @@ - + @@ -27165,7 +27147,7 @@ - + @@ -27626,7 +27608,7 @@ - + @@ -27656,7 +27638,7 @@ - + @@ -27722,7 +27704,7 @@ - + @@ -27732,7 +27714,7 @@ - + @@ -27876,7 +27858,7 @@ - + @@ -27923,9 +27905,9 @@ - + - + @@ -27937,9 +27919,9 @@ - + - + @@ -27960,7 +27942,7 @@ - + @@ -27990,7 +27972,7 @@ - + @@ -28010,7 +27992,7 @@ - + @@ -28024,7 +28006,7 @@ - + @@ -28036,12 +28018,12 @@ - + - + @@ -28051,15 +28033,15 @@ - + - + - + @@ -28077,20 +28059,20 @@ - - + + - - + + - + @@ -28100,7 +28082,7 @@ - + @@ -28108,11 +28090,11 @@ - + - + @@ -28167,19 +28149,19 @@ - - + + - + - + @@ -28188,27 +28170,27 @@ - + - + - + - + - + @@ -28221,7 +28203,7 @@ - + @@ -28236,7 +28218,7 @@ - + @@ -28267,11 +28249,11 @@ - + - - + + @@ -28295,12 +28277,12 @@ - + - + @@ -28308,18 +28290,18 @@ - + - + - + - + @@ -28360,7 +28342,7 @@ - + @@ -28368,14 +28350,14 @@ - + - + @@ -28391,7 +28373,7 @@ - + @@ -28402,7 +28384,7 @@ - + @@ -28441,7 +28423,7 @@ - + @@ -28449,7 +28431,7 @@ - + @@ -28468,7 +28450,7 @@ - + @@ -28507,11 +28489,11 @@ - + - + @@ -28538,10 +28520,10 @@ - + - + @@ -28579,7 +28561,7 @@ - + @@ -28607,11 +28589,11 @@ - - + + - + @@ -28655,9 +28637,9 @@ - + - + @@ -28723,7 +28705,7 @@ - + @@ -28743,8 +28725,8 @@ - - + + @@ -28771,7 +28753,7 @@ - + @@ -28788,7 +28770,7 @@ - + @@ -28801,17 +28783,17 @@ - + - + - + @@ -28838,9 +28820,9 @@ - + - + @@ -28863,7 +28845,7 @@ - + @@ -28874,7 +28856,7 @@ - + @@ -28937,9 +28919,9 @@ - + - + @@ -28953,9 +28935,9 @@ - + - + @@ -28973,8 +28955,8 @@ - - + + @@ -28985,7 +28967,7 @@ - + @@ -28993,7 +28975,7 @@ - + @@ -29005,7 +28987,7 @@ - + @@ -29015,12 +28997,51 @@ + + + + + + + + + + + + + + + + + + + + +

+ ...da es sich ja nur um die Factory handelt, +

+

+ nicht um das AppState-Singleton selber, welches ja ohnehin nur von main.cpp +

+

+ verwendet werden sollte. Aber das deutet darauf hin, daß irgend etwas mit der +

+

+ Initialisierung von Statics "faul" ist, wenn shared objects dynamisch geladen werden. +

+ + +
+ +
+
+
- + @@ -29034,7 +29055,7 @@ - + @@ -29065,7 +29086,7 @@ - + @@ -29095,7 +29116,7 @@ - + @@ -29150,7 +29171,7 @@ - + @@ -29198,14 +29219,14 @@ - + - + - + @@ -29257,7 +29278,7 @@ - + @@ -29301,7 +29322,7 @@ - + @@ -29319,7 +29340,7 @@ - + @@ -29346,7 +29367,7 @@ - + @@ -29360,7 +29381,7 @@ - + @@ -29392,7 +29413,7 @@ - + @@ -29415,11 +29436,11 @@ - + - + @@ -29437,20 +29458,20 @@ - + - + - + - + @@ -29461,7 +29482,7 @@ - + @@ -29470,21 +29491,21 @@ - + - + - + - + @@ -29492,14 +29513,14 @@ - + - + - + @@ -29510,7 +29531,7 @@ - + @@ -29520,7 +29541,7 @@ - + @@ -29536,7 +29557,7 @@ - + @@ -29544,7 +29565,7 @@ - + @@ -29576,9 +29597,9 @@ - + - + @@ -29622,7 +29643,7 @@ - + @@ -29630,7 +29651,7 @@ - + @@ -29643,11 +29664,11 @@ - + - + @@ -29694,7 +29715,7 @@ - + @@ -29702,12 +29723,12 @@ - + - + @@ -29778,10 +29799,10 @@ - + - + @@ -29828,9 +29849,9 @@ - + - + @@ -29845,7 +29866,7 @@ - + @@ -29860,7 +29881,7 @@ - + @@ -29880,18 +29901,18 @@ - + - + - - + + - + @@ -29916,13 +29937,13 @@ - + - + @@ -29930,7 +29951,7 @@ - + @@ -30007,15 +30028,15 @@ - + - + - + @@ -30025,7 +30046,7 @@ - + @@ -30034,14 +30055,14 @@ - + - - + + @@ -30058,10 +30079,10 @@ - + - + @@ -30070,7 +30091,7 @@ - + @@ -30111,7 +30132,7 @@ - + @@ -30161,7 +30182,7 @@ - + @@ -30275,7 +30296,7 @@ - + @@ -30376,7 +30397,7 @@ - + @@ -30387,6 +30408,7 @@

+
@@ -31555,7 +31577,7 @@ - + @@ -31587,7 +31609,7 @@ - + @@ -31599,7 +31621,7 @@ - + @@ -31949,10 +31971,256 @@ - - + + + + + + + + + + + + + + + + + + + +

+ wenn ein Template ein statisches member-Feld hat, +

+

+ dann ist zusätzlich eine getemplatete Definition dieses Feldes notwendig. +

+

+ Diese wird erst generiert, wenn der erste odr-use des statischen Member-Feldes passiert. +

+

+ Dieser odr-use kann nun z.B. aus einer Funktion des Template heraus erfolgen +

+

+ Allerdings beobachte ich, daß dann der ctor-Aufruf zur Initialisierung erst nach dem Zugriff auf +

+

+ das member-Feld passiert, sofern der Aufruf und damit die Instanz des umschließenden Template +

+

+ selber aus einem statischen Initialisierungs-Kontext heraus erfolgt. +

+ + +
+ +
+ + + + + + + + + +

+ +

+

+ #include <iostream> +

+

+ +

+

+ using std::cout; +

+

+ using std::endl; +

+

+ +

+

+ template<typename T> +

+

+ class Factory +

+

+   { +

+

+   public: +

+

+     T val; +

+

+     +

+

+     Factory() +

+

+       : val{} +

+

+       { +

+

+         cout << "Factory-ctor  val="<<val<<endl; +

+

+       } +

+

+   }; +

+

+ +

+

+ +

+

+ template<typename T> +

+

+ class Front +

+

+   { +

+

+   public: +

+

+     static Factory<T> fac; +

+

+     +

+

+     Front() +

+

+       { +

+

+         cout << "Front-ctor    val="<<fac.val<<endl; +

+

+         fac.val += 100; +

+

+       } +

+

+     +

+

+     T& +

+

+     operate () +

+

+       { +

+

+         cout << "Front-operate val="<<fac.val<<endl; +

+

+         ++ fac.val; +

+

+         return fac.val; +

+

+       } +

+

+   }; +

+

+ +

+

+ template<typename T> +

+

+ Factory<T> Front<T>::fac; +

+

+ +

+

+ +

+

+ namespace { +

+

+   Front<int> front; +

+

+   int global_int = front.operate(); +

+

+ } +

+

+ +

+

+ +

+

+ +

+

+ int +

+

+ main (int, char**) +

+

+   { +

+

+     Front<int> fint; +

+

+     +

+

+     int& i = fint.operate(); +

+

+     cout << "main:         val="<<i<<endl; +

+

+     cout << "global_int.......="<<global_int<<endl; +

+

+     +

+

+     return 0; +

+

+   } +

+ + +
+
+
@@ -31969,7 +32237,7 @@ - + @@ -33435,7 +33703,7 @@ - +