🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3885

Re: static members as members of a metacla

#3885
From: Steve Clamage
Date: Mon, 01 Apr 1996 19:06
43 lines
2476 bytes
In article 96Mar29114545@gabi.gabi-soft.fr, kanze@gabi-soft.fr (J. Kanze) writes:
>In article <4jckdc$ad6@engnews1.Eng.Sun.COM> clamage@Eng.Sun.COM (Steve
>Clamage) writes:
>
>    [...]
>|> I believe a reasonable solution to the problem of initialization of
>|> non-local static data is not to use non-local static data!
>
>|> Instead of a static data object or static class data member, use a 
>|> function with a local static object.
>    [...]
>|> Only two features are missing, compared to non-local static objects:
>
>|> 1. If you never reference an object, it is never initialized.
>
>But is this guaranteed by the standard anyway?  

Assuming a program terminates normally (returning from main or
calling exit), I believe that every non-local static object defined
in a module that is somehow referenced will eventually be intialized.


>|> 2. The order of destruction remains unspecified. If that is a problem,
>|> possibly the static objects could be of a type which has a do-nothing
>|> destructor and a "destroy" member function which could be called
>|> explicitly at the proper time.
>
>I thought that the order of destruction was the reverse of
>initialization.

I believe the current draft says that. Few current implementations
ensure that result, and whether that guarantee will remain in the standard
is under discussion.

---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]
Technical Details
Message-ID: <4jp7st$lbj@engnews1.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
References: <KANZE.96Mar29114545@gabi.gabi-soft.fr>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
From: clamage@Eng.Sun.COM (Steve Clamage)
Newsgroups: comp.std.c++
Subject: Re: static members as members of a metacla
Date: 01 Apr 1996 11:06:26 PST
Organization: Sun Microsystems Inc.
Approved: austern@isolde.mti.sgi.com
Message-ID: <4jp7st$lbj@engnews1.Eng.Sun.COM>
References: <KANZE.96Mar29114545@gabi.gabi-soft.fr>
Reply-To: clamage@Eng.Sun.COM
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: 1 Apr 1996 18:39:25 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMWApM0y4NqrwXLNJAQE5kQIA0AhmZg5WtI6CJbboIHNOrTyIwhoAeh5Q
 wvHrGalrYB7Pl6DYQcb4hTa3Iobpf2MvKwezL4mW6qHqkVvzKKnYNg==
 =MCBe
Originator: austern@isolde.mti.sgi.com