Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-08-14 18:14:50

Philip Nash wrote:

> There may be other problems with it - maybe someone else could give some
> examples - but as I see it a likely obstacle to having a Loki-like Singleton
> accepted into boost is that it relies heavily on atexit(), which seems to be
> inconsistently implemented across compilers.
> Does anyone have any workarounds for that?

        Sure: create an object in main().
        Pass a pointer to it to every routine that needs it.
        Destroy the object before exiting main.

If passing a pointer to every single routine is too onerous,
make it a non-static member of some class and use methods
which can access it through the 'this' pointer.

Or change to a language which supports function closures,
and put it in an outer routine (this is implicit coupling,
but you choose how 'global' it is, in effect, the nested
routines are member of the environment object).

So what use is a 'singleton' pattern now?
I don't see an 'pattern' here other than 'auto storage'.

John (Max) Skaller, mailto:skaller_at_[hidden] 
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
New generation programming language Felix
Literate Programming tool Interscript

Boost list run by bdawes at, gregod at, cpdaniel at, john at